Jump to content

If else error


leest

Recommended Posts

I have an if else query i have worked through a tutorial to try and get the structure correct, however when i run the test script i get errors.  I know the query works but when placed in the if else statement i get an error on line 22 which is

 

$candidate_id = $_GET["candidate_id"];

 

 

the whole script and error message are shown below.

Any guidance would be appreciated, thanks.

 



include '../folder1/folder2/db1.php';
$username = $_SESSION['username'];
$SID = $_SESSION['SID'];
$query = "SELECT username FROM candidate WHERE username ='$username' AND site_id ='$SID'";
$result = mysql_query($query)or die(mysql_error());
$num = mysql_num_rows($result); //will be either 0 if its not there or more than zero if it is
if($num > 0) { //checks for an entry


     //***** Gets Candidate ID from candidate table  *************//
     $username = $_SESSION['username'];
     $query = "SELECT * FROM candidate WHERE username ='$username'"; 	 
     $result = mysql_query($query) or die(mysql_error());
     $row = mysql_fetch_array($result) or die(mysql_error());
     $candidate_id = $row['candidate_id']; }

   elseif 
   (
    $candidate_id = $_GET["candidate_id"];
$query = "SELECT username FROM candidate_joborder WHERE username ='$username' AND candidate_id ='$candidate_id'";
    $result = mysql_query($query)or die(mysql_error());
    $num = mysql_num_rows($result); //will be either 0 if its not there or more than zero if it is
    if($num > 0) { //checks for an entry//	
)
else
echo "test";

 

The error

 

"Parse error: syntax error, unexpected ';' in /public_html/search/test.php on line 22"

Link to comment
https://forums.phpfreaks.com/topic/84079-if-else-error/
Share on other sites

first of all you have to have the { braces instead of the ( braces... secondly the line throwing the errors is

 

elseif 

 

now you are specifying a elseif but not specifiying a condition....

 

also please block all your if statements if they are one liners also it leads to much readable code...

 

hopes it helpful...

Link to comment
https://forums.phpfreaks.com/topic/84079-if-else-error/#findComment-427977
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.