It's as if ! != !
Posted: Fri Sep 22, 2006 3:13 am
I've got the simple code to insert into a DB, which inserts fine, but I want an error message to display if a numeric field isn't numeric.
But this always displays "Please use digits for your age" and the insert runs fine. Can anybody see what's gone wrong?
Code: Select all
$valOne = $_REQUEST["valOne"];
$valTwo = $_REQUEST["valTwo"];
$valThree = $_REQUEST["valThree"];
mysql_connect("x", "x", "x");
mysql_select_db("poll");
$q = mysql_query("SELECT * FROM test");
$numRows = mysql_numrows($q);
$count = $numRows + 1;
if (!(is_numeric($valThree))) {
echo "Please use digits for your age"; }
else {
mysql_query("INSERT into test(count, fName, sName, age) VALUES ('$count', '$valOne', '$valTwo', '$valThree')");
echo "Inserted"; }