Page 1 of 1

[solved] if condition does not equal INT

Posted: Wed Sep 21, 2005 12:43 am
by robster
How do you do that?!

:)

I've got a database field with text in it which is now slowly being replaced by an integer reference instead.

Code: Select all

IE:  "fluffy shampoo" is now  "1".
What I'm trying to do is this kind of error checking:

Code: Select all

if field data IS NOT an INT
{
do stuff with a function that expects an INT
}
else
{
echo "this is old data";
}

So, how does one read a value and determine if there's text or an integer in there?

bizzarro!!

:)

Rob

Posted: Wed Sep 21, 2005 12:45 am
by hawleyjr
is_int()

http://us3.php.net/manual/en/function.is-int.php

or

Code: Select all

ereg('[^0-9]', $int)

Posted: Wed Sep 21, 2005 12:47 am
by robster
is there NOTHING that is not easily do-able with PHP?! LOL :)

Thank you so much. They've thought of everything have they not!?

(looks like this is the function I'm after btw, very similar, but slightly different: http://us3.php.net/manual/en/function.is-numeric.php)

rob

Posted: Wed Sep 21, 2005 1:14 am
by hawleyjr
Is Numeric and is Int are two different things... :) :)

Posted: Wed Sep 21, 2005 1:25 am
by robster
true, I think I asked my question slightly incorrectly.

It was the ability to test for a numeric value rather than an INT value.
But I was lead straight to the answer, which I really appreciate.

Thanks again,

rob