September 14, 201016 yr *think ive sorted this now but cant see how to delete this thread!* Hi all, attempting to upload my first php script, having probs. here is the code: <body> <h2>Enter Your 1 Rep Max for Barbell Bench Press</h2> <?php if (!isset ($_POST['submit'] )) { ?> <form method="post" action="names.php"> Enter your Bench Press in kg: <br /> <input type="text" name="weight" size="3" /> <p> <input type="submit" name="submit" value="Submit" /> </form> <?php } else { $weight = $_POST ['weight'] ; if ($weight <= 70) { echo "You're a fanny. You'd make a good 'before' picture"; } elseif ($weight > 70 && $weight <= 90) { echo "Not bad, you might make the cover of Men's health within a year or two" } elseif ($weight > 90 && $weight <= 120) { echo "Good work, keep it up, good weight for a footballer or jockey"; } elseif ($weight > 120 && $weight <= 150) { echo "Excellent, you must look like a Maximuscle advert"; } else { echo "You've been guzzling the steds"; } } </body> It's exactly as shown in my book PHP a beginners guide; but keep getting the following error: Parse error: syntax error, unexpected '}', expecting ',' or ';' in /homepages/44/d331383884/htdocs/names.php on line 27 this is line 27 - } elseif ($weight > 90 && $weight <= 120) { tried moving stuff about but no luck so far
September 15, 201016 yr Replace this line right here echo "Not bad, you might make the cover of Men's health within a year or two" with echo "Not bad, you might make the cover of Men's health within a year or two"; You were missing the ; at the end of that echo key thing when learning php the error may not always be on that exact line it says it is so check the line above to hope this helps cheers
September 16, 201016 yr Not to go off-topic or anything... key thing when learning php the error may not always be on that exact line it says it is so check the line above to I've never come across this - unless an error is creating a different line to cause an error. Maybe you're not adding a new line at the end of your files?
September 16, 201016 yr Your PHP book told you to write: "You're a fanny. You'd make a good 'before' picture"? HAHA!
September 17, 201016 yr Not to go off-topic or anything... I've never come across this - unless an error is creating a different line to cause an error. Maybe you're not adding a new line at the end of your files? really? it happens all the time due to the nature of how php parses files. for example <? class made_up { function meh(){ foreach($array as $item){ } } running that gives me a error that exhibits what webdesigner93 pointed out, the error is between line 7-10 line 13 doesn't exist and is out of the class definition so the error is misleading and the real error is up a few lines... to someone who doesn't know php errors in and out the advice given was good that's all im saying... Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /var/www/test.php on line 13 && lol thanks Lewwy for pointing that out, dint notice
Create an account or sign in to comment