Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Can someone have a look at this php code please?

Featured Replies

*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

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 :)

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?

Your PHP book told you to write: "You're a fanny. You'd make a good 'before' picture"?

 

HAHA!

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.