Jump to content

Newbie PHPer in Need


!!!!!

Recommended Posts

Okay, I am readin a BOOk on PHP and so I am just writing newbie scripts. Why isn't this working?

[code]<?php
$outputString = "Hello world!";
$bus = "Thewwra";
$es = "Is a great Company";
$or = "50";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


<html>

<head>
<title>Hi</title>
</head>
<body>

<?php
if ($or > 58)
print "58 greater than Variable.";
else
print "58 is less than Variable.";
break;
echo "$bus $es";
break;
echo "Please join thewwra in our way to sell tons!";
?>

</body>
</html>[/code]
Link to comment
Share on other sites

change
[code]
<?php
if ($or > 58)
print "58 greater than Variable.";
else
print "58 is less than Variable.";
break;
echo "$bus $es";
break;
echo "Please join thewwra in our way to sell tons!";
?>
[/code]
to
[code]
<?php
if ($or > 58)
{
print "58 greater than Variable.";
}
else
{
print "58 is less than Variable.";
}
echo $bus.$es;
echo "Please join thewwra in our way to sell tons!";
?>
[/code]
Link to comment
Share on other sites

[quote author=fert link=topic=118033.msg481981#msg481981 date=1165728907]
change
[code]
<?php
if ($or > 58)
print "58 greater than Variable.";
else
print "58 is less than Variable.";
break;
echo "$bus $es";
break;
echo "Please join thewwra in our way to sell tons!";
?>
[/code]
to
[code]
<?php
if ($or > 58)
{
print "58 greater than Variable.";
}
else
{
print "58 is less than Variable.";
}
echo $bus.$es;
echo "Please join thewwra in our way to sell tons!";
?>
[/code]
[/quote]Umm, that didn't do anything, but thanks for trying. It says: Fatal error: Cannot break/continue 1 level in /home/thewwrac/public_html/mine.php on line 27

[code]<?php
$outputString = "Hello world!";
$bus = "Thewwra";
$es = "Is a great Company";
$or = "50";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


<html>

<head>
<title>Hi</title>
</head>
<body>

<?php
if ($or > 58)
{
print "58 greater than Variable.";
}
else
{
print "58 is less than Variable.";
}
break;
echo "$bus $es";
break;
echo "Please join thewwra in our way to sell tons!";
?>

</body>
</html>[/code]still need some fixin', thanks!
Link to comment
Share on other sites

try this instead:

[code]
if (count($or) > 58)
print "58 greater than Variable.";
else
print "58 is less than Variable.";
[/code]

also, you don't need those "break"s in your code. try it - it'll work fine without them. another way to create your if statements is with the { and } characters. you might find this method to be easier to organize and view your code when you start using more than 1 line of code in an if statement.

[code]
if (count($or) > 58) {
      print "58 greater than Variable.";
      // a second line of code is acceptable when you use { and }
      // and even more lines of code
} else {
      print "58 is less than Variable.";
      // even more code
}
[/code]

hope this helps.
cheers,
.s
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.