Fatal error: Uncaught Error: Call to a member function


#85

Sorry, I don’t know what you are asking. What do you want the count variable to do, where are you going to use it? In your code above, you just increment it, then re-set it to zero inside your if clauses.


#86

If I put just that script into a html file, it relocates as you want it to. So the answer must lie in whatever else is going on in that code. Your count issue will stop it even trying to relocate, but I don’t understand why it doesn’t display the error alert.

O/T but you might want to be a bit more consistent - both of your script opening tags are introducing JS code, but you specify it differently for each one. I don’t know if it makes any difference.


#87
   $count=0;  
$sql  = "SELECT COUNT(*) `email` FROM customer WHERE `email`= `email`        ";

	
	
	
	
	
	if($count == 0){
  
    echo "<script language=\"JavaScript\">{ 
location.href=\"https://phpdelusions.net/mysqli/check_value\"; 
self.focus(); 
}</script>";
}


}else if($count > 0){

echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";

$count++;
}

i tried this wont work


#88

What does “won’t work” mean? You need to give a bit more information.

Is it just the parse error for when you have an extra close brace?


#89

no erros it goes all the time on same page


#90

If I execute the code as you posted it, I get:

( ! ) Parse error: syntax error, unexpected '}' in C:\wamp\www\sitepoint\jsrelocate.php on line 20

I don’t know why you don’t.

If I edit the code to remove the spurious close brace, it redirects as you expect it. I can’t think of any reasons why it’s not doing the same for you, so I don’t think I can offer anything else here. Hope you find out what was causing it.