View Full Version : How do I distinguish between numbers and letters in query string

07-05-2005, 08:48 PM
hi, I think this is easy but Im very new to php programing,

i want to + two numbers, this is the code:

if (is_string($var)) {echo "Enter the right data";} else
{if (is_string($varr)) {echo "Enter the right data";}}

$ress = $var + $varr;
echo "The answer is $ress ";

the prob is that when a user enters letters instead numbers it displays: "Enter the right data" but it continues doing the other task and ussumes that $var and $varr are = to 0 and + them giving the other message too.

thanks in advanced

07-05-2005, 09:55 PM
Everything that is sent vie POST/GET is a string. Try using is_numeric() (http://www.php.net/is_numeric) instead.