!!!!! Posted December 10, 2006 Share Posted December 10, 2006 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><?phpif ($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] Quote Link to comment Share on other sites More sharing options...
fert Posted December 10, 2006 Share Posted December 10, 2006 change[code]<?phpif ($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]<?phpif ($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 Link to comment Share on other sites More sharing options...
!!!!! Posted December 10, 2006 Author Share Posted December 10, 2006 [quote author=fert link=topic=118033.msg481981#msg481981 date=1165728907]change[code]<?phpif ($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]<?phpif ($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><?phpif ($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! Quote Link to comment Share on other sites More sharing options...
fert Posted December 10, 2006 Share Posted December 10, 2006 you need to remove th break; from your code, because you only use that when escaping a loop. Quote Link to comment Share on other sites More sharing options...
Mr_Pancakes Posted December 10, 2006 Share Posted December 10, 2006 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 Quote Link to comment Share on other sites More sharing options...
fert Posted December 10, 2006 Share Posted December 10, 2006 count($or) won't work because $or isn't an array. Quote Link to comment Share on other sites More sharing options...
!!!!! Posted December 10, 2006 Author Share Posted December 10, 2006 [quote author=fert link=topic=118033.msg481987#msg481987 date=1165729435]count($or) won't work because $or isn't an array.[/quote]Okay, it works, but how do I break Echo and Print? Thanks a lot by the way Quote Link to comment Share on other sites More sharing options...
Mr_Pancakes Posted December 10, 2006 Share Posted December 10, 2006 actually, upon a second review, count($or) woudn't work regardless because $or is equal to a string while the if statement is comparing to an integer.try first setting $or equal to an integer as well.[code]$or = 50;[/code] Quote Link to comment Share on other sites More sharing options...
fert Posted December 10, 2006 Share Posted December 10, 2006 echo "<br >"; Quote Link to comment Share on other sites More sharing options...
Mr_Pancakes Posted December 10, 2006 Share Posted December 10, 2006 you can also insert an HTML break as well.[code]echo "blahhhhh <br />";[/code]and if you wanna get picky, you could add a server line break to it all to line feed your code:[code]echo "blahhhhh <br />\n";[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.