Jump to content

[SOLVED] elseif parse error


gwydionwaters

Recommended Posts

i am trying to write an esleif sequence and for some reason i get a parse error on a line that should be no different than the last

 

if ($browse=('author')) {
$var1 = "author = '$author'";
$query .= $var1;
}
elseif ($browse=('type')) {
$var1 = "type = '$type'";
$query .= $var1;
}
esleif ($browse=('use')) {            //** Line 24 is here **
$var1 = "func = '$func'";
$query .= $var1;
}
elseif ($browse=('cost <=')) {
$var1 = "cost = '$cost'";
$query .= $var1;
}
elseif ($browse=('rating')){
$var1 = "rate = '$rate'";
$query .= $var1;
}
else 
echo 'Sorry an error occurred, please try again';
endif;

 

i tried to use : instead of curly brackets but apparently i need them becuase i have multiple actions in my elseif?

either way i try it won't work, the problem is before i had it as just if statements in sequence and for some reason it doesn't work, if i comment out everything but the first if and run it then it works. but obviously only for author :)

Link to comment
Share on other sites

Don't double post!

 

Open your eyes and look at your spelling...

esleif ($browse=('use')) {   

 

Should be:

 

elseif ($browse == 'use') {    

 

And like my other post said you need to use == not = or else the last elseif statement will always be true.

Link to comment
Share on other sites

Open your eyes and look at your spelling...

Kind of harsh wouldn't you say?  You sure like flaming people

 

Sorry to be like this but when people double post it irritates me.  It wastes everyone elses time and is ignorant.  So, as far as your question, "Kind of harsh wouldn't you say?", my answer is NO.

 

Flaming?  Far from it...

Link to comment
Share on other sites

Open your eyes and look at your spelling...

Kind of harsh wouldn't you say?  You sure like flaming people

 

Sorry to be like this but when people double post it irritates me.  It wastes everyone elses time and is ignorant.  So, as far as your question, "Kind of harsh wouldn't you say?", my answer is NO.

 

Flaming?  Far from it...

Guess I can see your point, I did read the other thread and you answered the exact same question there, quite politely at that.  As coders we should ALL go through each line of code and check for spelling and typos before we post a thread here ... gwydionwaters as well as utilize all the tools you have at your hands, such as google ...

Link to comment
Share on other sites

Open your eyes and look at your spelling...

Kind of harsh wouldn't you say?  You sure like flaming people

 

Sorry to be like this but when people double post it irritates me.  It wastes everyone elses time and is ignorant.  So, as far as your question, "Kind of harsh wouldn't you say?", my answer is NO.

 

Flaming?  Far from it...

Guess I can see your point, I did read the other thread and you answered the exact same question there, quite politely at that.  As coders we should ALL go through each line of code and check for spelling and typos before we post a thread here ... gwydionwaters as well as utilize all the tools you have at your hands, such as google ...

quite harsh, yes. i posted in two places not knowing which forum was appropriate. if i make you angry i'd rather you didn't post at all than be a jerk. also i posted both within moments of one another so i did not know you had already answered me, people usually don't answer right away. thank you all for helping, i do appreciate you taking the time to read over my probably mindane issues and finding solutions for me. i really do.

 

what am i trying to accomplish? i made a menu driven database browser, for lack of a better term. users can select options from drop downs that will return database entries matching the option used.

 

in regards to my problem i found a solution using a different call, that being switch/case and it is working great :) the code i created now is such

switch ($browse)
{
case author:
    $query .= "author = '$author1'";
$term = $author1;
  break;  
case type:
    $query .= "type = '$type1'";
$term = $type1;
  break;
case func:
$browse = "use";
$query .= "func = '$func1'";
$term = $func1;
  break;
case cost:
$browse = "price < =";
$query .= "cost <= '$cost1'";
$term = $cost1;
  break;
case rating:
$query .= "rate = '$rate1'";
$term = $rate1;
  break;
default:
echo 'Sorry an error occurred, please try again';
}

 

sorry to have offended some, and again thank you muchly to those who have been patient with me

Link to comment
Share on other sites

lol yeah, but now i also know how to do a case also. :D

it's funny, i must be dyslexic: when i was reading the response about the typo, with a quote of my code, i had to read it five times before i saw the typo ... and i knew where to look

 

Don't worry, we all have those kinds of days...  :P

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.