Jump to content

Archived

This topic is now archived and is closed to further replies.

infophiliac

isset conditional issue

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.

Share this post


Link to post
Share on other sites
Looking at your code it is fine. However I think the error is comming from above line 28.

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

×

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.