Cannibal_Monkey Posted October 7, 2006 Share Posted October 7, 2006 I've looked around and simply can't find the error. I've tried all combos of else, if, and or for the 2nd part of the code, with and without that stuff after it I can think of, and none of it works (though from what I've seen, what I have there currently should work). The error I get is "Parse error: parse error, unexpected T_LOGICAL_OR in H:\Program Files (x86)\xampp\htdocs\learn.php on line 15"Here's my code:[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><?php$b = 1;$c = 1;if ($b == $c){ $a = "They are equal"; echo $a;};or else if ($b !=, <> $c){ $a = "They are not equal"; echo $a}?><body></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23310-just-cant-figure-out-why-this-doesnt-work/ Share on other sites More sharing options...
redbullmarky Posted October 7, 2006 Share Posted October 7, 2006 i'm not sure what youre trying to do here:[code]or else if ($b !=, <> $c)[/code]as you're using two 'not equal' operators. you only need one. try:[code]or else if ($b <> $c)[/code][b]edit:[/b] in fact, you've got a few errors (sorry, i missed them first time looking...)[code]<?php$b = 1;$c = 1;if ($b == $c){ $a = "They are equal";}else { $a = "They are not equal";}echo $a;?>[/code]you dont even need the second check. the first one, if $b == $c will check if $b is equal to $c. an else statement is enough to deal with the event that they're not equal, without the need to check if $b <> $c Quote Link to comment https://forums.phpfreaks.com/topic/23310-just-cant-figure-out-why-this-doesnt-work/#findComment-105689 Share on other sites More sharing options...
Cannibal_Monkey Posted October 7, 2006 Author Share Posted October 7, 2006 Thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/23310-just-cant-figure-out-why-this-doesnt-work/#findComment-105696 Share on other sites More sharing options...
kwstephenchan Posted October 8, 2006 Share Posted October 8, 2006 don't know if you got the else if right, else if should be coded as elseif$b = 1;$c = 1;if ($b == $c){ $a = "They are equal";}elseif ($b <> $c){ $a = "They are not equal";}echo $a; Quote Link to comment https://forums.phpfreaks.com/topic/23310-just-cant-figure-out-why-this-doesnt-work/#findComment-105919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.