Jump to content

[SOLVED] Parse error: syntax error, unexpected T_STRING


Recommended Posts

Hi,

I have a page called results.php, that gets variables from a form and puts them into a mysql database.

I get an error when the form is submitted:-

Parse error: syntax error, unexpected T_STRING in /hosted/subs/ulmb.com/g/r/greenshawaida/public_html/results.php on line 12

Lines 12-24 are just a simple if statement.

if ($exercise == 0 Hours) {
    $fit1 == 0
} elseif ($exercise == 1 Hours) {
    $fit1 == 1;
} elseif ($exercise == 2 Hours) {
    $fit1 == 2;
} elseif ($exercise == 3 Hours) {
    $fit1 == 3;
} elseif ($exercise == 4 Hours) {
    $fit1 == 4;
} else {
    $fit1 == 5;
}

why isn't it working. i'm not very good at writing php, so if there is an obvious error i'm sorry!

Hello,

 

There are 2 mistakes in your code block

- First of missing ';' (Also pointed by rarebit)

 

- And another one of not using quotes while comparing string in if-elseif conditions. Modify your code with the following code block

if ($exercise == '0 Hours') {
    $fit1 == 0;
} elseif ($exercise == '1 Hours') {
    $fit1 == 1;
} elseif ($exercise == '2 Hours') {
    $fit1 == 2;
} elseif ($exercise == '3 Hours') {
    $fit1 == 3;
} elseif ($exercise == '4 Hours') {
    $fit1 == 4;
} else {
    $fit1 == 5;
}

 

Hope this will solve your issue.

Regards

 

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.