Jump to content

isset conditional issue


infophiliac

Recommended Posts

I've been running into the same problem on a number of different pages that I've copied out of the book from which I'm learning PHP. The site for the book doesn't list any corrections to this code, so I assume it's a problem that I'm having and not an error in the book.

I'm using PHP v. 4.4.1 on the FreeBSD OS. I'm hosted by Startlogic.com.

An example of one that has given me trouble is:

[code]
if (isset($_POST['interests'])) {
    $interests = TRUE;
} else {
    $interests = NULL;
    echo '<p><font color="red">You forgot to enter your interests!</font></p>;
}
[/code]

The error message:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/wordofno/public_html/learningphp/handle_about.php on line 28

Line 28 yere is the first line of quoted code, but nowhere in that line (or any of the subsequent lines) is a semi-colon or comma called for and not used.

Any insights would be appreciated.
Link to comment
Share on other sites

[!--quoteo(post=369666:date=Apr 28 2006, 03:11 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 28 2006, 03:11 PM) [snapback]369666[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Looking at your code it is fine. However I think the error is comming from above line 28.
[/quote]

Bugger. OK, here's all the body leading up to what I previously posted.

[code]
<body>

<?php # Script 2.9 - handle_about.php




if (!empty($_POST['name'])) {
    $name = stripslashes($_POST['name']);
} else {
    $name = NULL;
    echo '<p><font color="red">You forgot to enter your name!</font></p>;
}



if (isset($_POST['interests'])) {
    $interests = TRUE;
} else {
    $interests = NULL;
    echo '<p><font color="red">You forgot to enter your interests!</font></p>;
}
[/code]



Everything still look OK? This has occured on every page on which I've tried to use the isset conditional and it's threatening to drive me buggy.

Link to comment
Share on other sites

Just as I though, You have a missing [b]'[/b] on this line:
[code] echo '<p><font color="red">You forgot to enter your name!</font></p>;[/code]
Notice there is no ' before the ; in the above code. To solve this just put a ' before the ; so you line is like this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] echo '<p><font color="red">You forgot to enter your name!</font></p>[!--sizeo:3--][span style=\"font-size:12pt;line-height:100%\"][!--/sizeo--][!--coloro:red--][span style=\"color:red\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--][!--sizec--][/span][!--/sizec--];[/quote]
Link to comment
Share on other sites

[!--quoteo(post=369670:date=Apr 28 2006, 03:25 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 28 2006, 03:25 PM) [snapback]369670[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Just as I though, You have a missing [b]'[/b] on this line:
[code] echo '<p><font color="red">You forgot to enter your name!</font></p>;[/code]
Notice there is no ' before the ; in the above code. To solve this just put a ' before the ; so you line is like this:
[/quote]

...and this is why I'm posting on the newbie board. Thanks man!
Link to comment
Share on other sites

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.