Jump to content


Photo

isset conditional issue


  • Please log in to reply
4 replies to this topic

#1 infophiliac

infophiliac
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 April 2006 - 06:42 PM

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:

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

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.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 April 2006 - 07:11 PM

Looking at your code it is fine. However I think the error is comming from above line 28.

#3 infophiliac

infophiliac
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 April 2006 - 07:16 PM

[!--quoteo(post=369666:date=Apr 28 2006, 03:11 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 28 2006, 03:11 PM) View Post[/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.

<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>;
}



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.



#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 April 2006 - 07:25 PM

Just as I though, You have a missing ' on this line:
echo '<p><font color="red">You forgot to enter your name!</font></p>;
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]

#5 infophiliac

infophiliac
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 April 2006 - 07:32 PM

[!--quoteo(post=369670:date=Apr 28 2006, 03:25 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 28 2006, 03:25 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Just as I though, You have a missing ' on this line:
echo '<p><font color="red">You forgot to enter your name!</font></p>;
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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users