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]
Link to comment
Share on other sites

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