Im trying to use an if function within the else function of a preg_match command.
$month1data is fetched from CURL and has been checked to work.
The following code is:
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
However whenever the page is loaded it directs straight to the error page:
"http://www.website.com/error.php?error=2"
I have looked at several others posts but can't see what's wrong, is it possible to implement these methods in this way or is there just something missing?