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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.