Jump to content

Recommended Posts

if(mysql_num_rows($query) == 1)
{
	 $compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'");
	 $company = mysql_result($compny, 0);
	if(mysql_num_rows($company) == 0)
	{
		echo "Company not found";
		die();
	}
	 $getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1");
	 $getcompstat = mysql_result($getcompstt, 0); 
	elseif($getcompstat == "3")

Link to comment
https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/
Share on other sites

You should write something describing your problem rather than just post code.

 


if(mysql_num_rows($query) == 1)
{
$compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'");
$company = mysql_result($compny, 0);
if(mysql_num_rows($company) == 0)
{
	echo "Company not found";
	die();
}
$getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1");
$getcompstat = mysql_result($getcompstt, 0); 
elseif($getcompstat == "3")

 

You have an elseif there at the end that is not attached to any preceding if statement. 

 

if(mysql_num_rows($query) == 1)
{
	 $compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'");
	 $company = mysql_result($compny, 0);
	if(mysql_num_rows($company) == 0)
	{
		echo "Company not found";
		die();
	}
	 $getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1");
	 $getcompstat = mysql_result($getcompstt, 0); 
	elseif($getcompstat == "3")
	{
		echo "Cannot find company"; 
		die();
	}

 

Sorry for not explaining - I wasn't sure how to.

 

That is the elseif statement, from the elseif I am having trouble, as you know it is giving me errors.

You are running other statements after the preceding if but before you use elseif.  elseif must come immediately after the close of the preceding if:

 

if(condition1)
{
      echo "foo";
}//end of if
elseif(condition2)
{
     echo "bar";
}

 

You have something like:

if(condition1)
{
      echo "foo";
}//end of if

echo "I have some stuff here after if but before elseif--I can't use elseif after this!

elseif(condition2)
{
     echo "bar";
}

You are running other statements after the preceding if but before you use elseif.  elseif must come immediately after the close of the preceding if:

 

if(condition1)
{
      echo "foo";
}//end of if
elseif(condition2)
{
     echo "bar";
}

 

You have something like:

if(condition1)
{
      echo "foo";
}//end of if

echo "I have some stuff here after if but before elseif--I can't use elseif after this!

elseif(condition2)
{
     echo "bar";
}

 

Thank you, I always thought you could add things in between, but nevermind x).

 

EDIT: Fixed, thank you.

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.