Jump to content


Photo

T_BOOLEAN_OR error


  • Please log in to reply
7 replies to this topic

#1 T_Hayden

T_Hayden
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 09 June 2006 - 04:54 PM

I am writing a validation for a simple form with validation. It takes the information and sends it to the validation page which either emails it or sends it back. I am getting an error after submitting the form.

Parse error: parse error, unexpected T_BOOLEAN_OR in /home/www/baptistsermonhost/test/collegeform/collegeform.php on line 23

Here is Line 23
if (empty($formVars['firstname'])) || (empty($formVars['lastname'])) || (empty($formVars['age'])) || (empty($formVars['line1'])) || (empty($formVars['city'])) || (empty($formVars['state'])) || (empty($formVars['areacode'])) || (empty($formVars['firstnumber'])) || (empty($formVars['secondnumber'])) {


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 June 2006 - 04:56 PM

you are missing the closing ) for the whole thing
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 09 June 2006 - 05:00 PM

No, actually this error happens because he/she missed the first parenthesis.
When it's added it, another error pops:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected '{' [/quote]
Then he/she can close the whole thing [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /].

Anyway, you don't need to use (empty($var)) || (empty($var2))... empty($var) || empty($var2) is enough.

if (empty($formVars['firstname']) || empty($formVars['lastname']) || empty($formVars['age']) || empty($formVars['line1']) || empty($formVars['city']) || empty($formVars['state']) || empty($formVars['areacode']) || empty($formVars['firstnumber']) || empty($formVars['secondnumber']))

~ D Kuang

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 June 2006 - 05:24 PM

okay so i missed the first one too. he needs to add ( ) around the whole darn thing.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 June 2006 - 05:32 PM

I would advise against using "if (empty($fld))" to determine if something was entered into a field. If someone enters a zero, "0", in a field, the emtpy() function will return "true".

Here's how I would do this:
<?php
$err = false;
foreach($_POST as $key=>$val)
    if (strlen(trim(stripslashes($val))) == 0) $err = true;
if ($err) echo "One of the fields was left blank";
?>

You could get slightly fancier:
<?php
$err = array();
foreach($_POST as $key=>$val)
    if (strlen(trim(stripslashes($val))) == 0) $err[] = $key;
if (!empty($err)) echo 'The following fields were left blank: ' . implode(', ',$err);
?>

Ken

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 June 2006 - 05:39 PM

or you could simply do like

if ( !$formVars['age'] || !$formVars['name'] || ...) { .. }

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 09 June 2006 - 05:48 PM

Crayon, if you use that you will still have problems like

0 is false
" " (whitespace) is true

Refer to this table:
[a href=\"http://www.php.net/manual/en/types.comparisons.php\" target=\"_blank\"]http://www.php.net/manual/en/types.comparisons.php[/a]

I think ken's suggestion is appropriate.
~ D Kuang

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 June 2006 - 06:09 PM

okay so i'll just shut up now :\
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users