yourfreemp4player Posted March 30, 2009 Share Posted March 30, 2009 Hi, I have a space in the word I need to use in an If Else statement and its killing my page. This is what I'm putting on my site... if($session->prize==Option 1){ echo " <img src=\"images/ipodstyle.jpg\"> ";}else{ } It says "Parse error: syntax error, unexpected ';' in /home/freemp4/public_html/index.php on line 62" However, if I was to change the word to "Option1", it works, but it doesn't help me, since I need the space in there... Is there anything I can do besides get rid of the space? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/151694-space-in-if-else-statement/ Share on other sites More sharing options...
A.White.89 Posted March 30, 2009 Share Posted March 30, 2009 Well, you could use option 1 as a string of "Option 1" but it all depends on how you are using it and how you make it. To me, I would do: $option = 'Option 1'; if($session->prize == $option) OR if Option changes, $option = 'Option ' . $num; // However you give the number (loop, db, etc.) if($session->prize == $option) Link to comment https://forums.phpfreaks.com/topic/151694-space-in-if-else-statement/#findComment-796618 Share on other sites More sharing options...
Yesideez Posted March 30, 2009 Share Posted March 30, 2009 ($session->prize==Option 1) Invalid code. If you want to check the contants in $session->prize to contain 'Option 1' then you need to place 'Option 1' inside a variable and check that or enclose double/single quotes around it and check it that way. That's presuming 'Option 1' is exactly what you want to check against. Link to comment https://forums.phpfreaks.com/topic/151694-space-in-if-else-statement/#findComment-796654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.