Jump to content

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


Cannibal_Monkey

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.