Jump to content


Photo

Just can't figure out why this doesn't work


  • Please log in to reply
3 replies to this topic

#1 Cannibal_Monkey

Cannibal_Monkey
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 07 October 2006 - 10:46 PM

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:

<!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>


#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 07 October 2006 - 10:50 PM

i'm not sure what youre trying to do here:

or else if ($b !=, <> $c)
as you're using two 'not equal' operators. you only need one. try:

or else if ($b <> $c)

edit: in fact, you've got a few errors (sorry, i missed them first time looking...)

<?php
$b = 1;
$c = 1;
if ($b == $c)
{
   $a = "They are equal";
}
else 
{
   $a = "They are not equal";
}

echo $a;
?>
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
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 Cannibal_Monkey

Cannibal_Monkey
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 07 October 2006 - 11:02 PM

Thanks :)

#4 kwstephenchan

kwstephenchan
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 08 October 2006 - 04:33 PM

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;






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users