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
https://forums.phpfreaks.com/topic/30091-newbie-phper-in-need/
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
https://forums.phpfreaks.com/topic/30091-newbie-phper-in-need/#findComment-138340
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
https://forums.phpfreaks.com/topic/30091-newbie-phper-in-need/#findComment-138343
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
https://forums.phpfreaks.com/topic/30091-newbie-phper-in-need/#findComment-138345
Share on other sites

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.