Spot The Error? :(

Hi Guys,

Please can you spot the error as i cant find it.


if(isset($_GET["check"]))
		{
		
		$res = CheckMail(trim($_POST["check"]));
		if (substr($res[0],0,3) == "250")
			  echo("<strong>Result</strong>: Email OK"); 
			  $query=sprintf( 
			  'INSERT INTO data VALUES ("", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")', 
			  mysql_real_escape_string($affid), 
			  mysql_real_escape_string($p), 
			  mysql_real_escape_string($title), 
			  mysql_real_escape_string($first), 
			  mysql_real_escape_string($last), 
			  mysql_real_escape_string($email), 
			  mysql_real_escape_string($dob), 
			  $ip,
			  mysql_real_escape_string($subid), 
			  $datenow, 
			  $timenow
			  ); 
			else 
			{
			  echo("<strong>Result</strong>: Bad"); 
			  echo("<br/><br/> Description: ".$res[0]);
			}  

The error only came up when i added the following and when i remove it the syntax error goes away.


$query=sprintf( 
			  'INSERT INTO data VALUES ("", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")', 
			  mysql_real_escape_string($affid), 
			  mysql_real_escape_string($p), 
			  mysql_real_escape_string($title), 
			  mysql_real_escape_string($first), 
			  mysql_real_escape_string($last), 
			  mysql_real_escape_string($email), 
			  mysql_real_escape_string($dob), 
			  $ip,
			  mysql_real_escape_string($subid), 
			  $datenow, 
			  $timenow
			  ); 

Any help would be great :slight_smile:

Thank you.

What is the error message you get?

Its a Syntax error that Dreamweaver CS5 is showing saying:

There is an Syntax Error on line 51. Code hinting may not work until you fix this error.

Line 51 is the line where the ‘else’ is.

Any help would be great.

Thank you.

You missed the opening and closing brace for this if statement: if (substr($res[0],0,3) == “250”). And you forgot to close the large if statement down at the bottom of your code: if(isset($_GET[“check”])).

Here is the full code with errors fixed:

if(isset($_GET["check"])) 
        { 
         
        $res = CheckMail(trim($_POST["check"])); 
        if (substr($res[0],0,3) == "250") {
              echo("<strong>Result</strong>: Email OK");  
              $query=sprintf(  
              'INSERT INTO data VALUES ("", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")',  
              mysql_real_escape_string($affid),  
              mysql_real_escape_string($p),  
              mysql_real_escape_string($title),  
              mysql_real_escape_string($first),  
              mysql_real_escape_string($last),  
              mysql_real_escape_string($email),  
              mysql_real_escape_string($dob),  
              $ip, 
              mysql_real_escape_string($subid),  
              $datenow,  
              $timenow 
              ); 
	  } else  { 
              echo("<strong>Result</strong>: Bad");  
              echo("<br/><br/> Description: ".$res[0]); 
          }  
            
            $query=sprintf(  
              'INSERT INTO data VALUES ("", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")',  
              mysql_real_escape_string($affid),  
              mysql_real_escape_string($p),  
              mysql_real_escape_string($title),  
              mysql_real_escape_string($first),  
              mysql_real_escape_string($last),  
              mysql_real_escape_string($email),  
              mysql_real_escape_string($dob),  
              $ip, 
              mysql_real_escape_string($subid),  
              $datenow,  
              $timenow 
              );  
	}