You had it pretty close  but try and make a few minor changes to it I've
tested the function below and it works for what you are trying to do. I
am not sure of a way to test for the null with eregi other than putting
and or statement in.  

if (eregi('^[0-9]+$', $_POST["gamt_$i"]) || $_POST["gamt_$i"] == null){

}

Kelly

-----Original Message-----
From: Robert E. Harvey, M.D. [mailto:[EMAIL PROTECTED]] 
Sent: February 19, 2003 6:54 PM
To: php
Subject: [PHP] Simple ereg question

Hello folks,

I'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
     {
       die("Non-numeric data entered in grass entry field(s).");
     }
}

No matter what I put in the fields, the program dies and I get the death

message.  What can I do to fix this?

TIA

Bob Harvey


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to