Re: simple ereg question
| From: | Robert E. Harvey, M.D. | Date: | Mon, 24 Feb 2003 00:01:21 +0000 |
| Subject: | Re: simple ereg question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136784@lists.php.net to get a copy of this message | ||
John W. Holmes wrote:
if (is_numeric($_POST["gamt_$i"]) or empty($_POST"gamt_$i")) or this: if (is_numeric($_POST["gamt_$i"]) || empty($_POST"gamt_$i")) I get this error message (my if statement is on line 5): *Parse error*: parse error, unexpected '\"', expecting ')' in */var/www/html/calc/pad_test.php* on line *5 * Now, where did that come from? TIA Bob HarveyI'd like to verify input data transferred from a form and make sure it is numeric data or null before my program executes. I am using this syntax, which doesn't work: for ($i=1;$i<=3;$i++) { if (ereg('[0-9]+','$_POST["gamt_$i"]')) { continue; } else {deathdie("Non-numeric data entered in grass entry field(s).");} } No matter what I put in the fields, the program dies and I get themessage. What can I do to fix this?Why not just use is_numeric() and empty()? No need for regular expressions. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ The is_numeric function works. However, when I try to make an "or" option out of the "if" clause, like this: