林内函数试图将preg_match
命令的else
函数中使用if
功能。如何使用如果其他功能
$month1data
从CURL中提取并已检查到工作。
下面的代码是:
global $attempt;
$attempt = mysql_escape_string($_GET['attempt']);
if (preg_match('/<td colspan=8(.*)<\/table/s', $month1data, $matches)) {
//Content found do stuff here
unset ($ch);
unset ($cache);
unset ($firstmonthdata);
unset ($matches);
} else { // start else preg match
if ($attempt = '3') { //start if attempt = 3
echo 'failed 3 times - showing error';
echo '<script type="text/javascript">
<!--
window.location = "http://www.website.com/error.php?error=2"
//-->
</script>';
} // end if attempt = 3
else { //start if attempt dont = 3
echo 'keep trying for 3 times';
$attempt = $attempt +1;
echo '<script type="text/javascript">
<!--
window.location = "http://www.website.com/page.php?email=' . $email . '&password=' . $password . '&attempt=' . $attempt . '"
//-->
</script>';
}// end if attempt dont 3 else
} // end else preg match
但是每当页面加载它直接引导到错误页面:
"http://www.website.com/error.php?error=2"
我已经看了几个人的职位,但不能看到什么错了,是否有可能以这种方式实现这些方法,或者只是缺少一些东西?
感谢你,我无法相信我错过了这一点,说明了为什么你不应该忽视简单的事情! – Jack
@Jack,请参阅http://stackoverflow.com/a/13783985/1592648以获取有关如何避免将来出现此类错误的提示。 = o) –
我会检查出来的,谢谢!这样一个真棒社区:) – Jack