First, thanks to all who offered suggestions with my "simple ereg question". I have been unable to get anything to work "properly" in spite of many good suggestions. The problem I want to solve is to ensure that input fields have either an integer number or are blank before the program proceeds. I am approaching the problem thusly:

for ($i=1;$i<=3;$i++)
{
echo $_POST["grass_$i"]; // Pollen name echo $_POST["gamt_$i"]; // Pollen amount
if (is_int($_POST["gamt_$i"]))
{
continue;
}
else
{
die("Non-numeric data entered in grass entry field(s).");
}
}


The two echo statements accurately return what data is in the two input fields. The program dies when there is integer data returned in the echo $POST["gamt_$i"] statement.

If I negate the expression in the if statement like so : if (!is_int($_POST["gamt_$i"]))
the program runs. Isn't that a bit weird?


It gets weirder. If I enter an alpha character with if (!is_int($_POST["gamt_$i"])), the program still runs but treats the alpha character as a 0.

How should I construct that if statement so that the program will only run with integer data or no data entered into the input fields?

TIA

Bob Harvey


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



Reply via email to