Forum Moderators: coopster

Message Too Old, No Replies

Simple ctype_digit question - quote in URL breaks logic

         

housecor

4:13 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



I'm validing the info in $_GET['id'] is all numeric using the following:

if (ctype_digit($_GET['id'])) {
continue with logic...
}

However, the above "breaks" and falsely returns true if an id with a single quote is placed in the URL. What am I missing?

Thanks in advance!

Little_G

4:33 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Hi,

I might be missing something but can't you use is_numeric() [uk2.php.net]

Andrew

jatar_k

4:46 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld housecor,

>> use is_numeric

you could but ctype_digit should work. I have never seen this happen, very strange. And you're sure it is a single quote breaking it?

You could test for quote first

I wonder if any other chars break it

housecor

5:44 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Ah! Sorry guys, I actually had a counter include that was pulling the URL and failing with any single quote because I wasn't escaping characters before doing the insert of the URL. Dumb mistake!

Jatar_k - I've been lurking for a long while and read many of your posts - guys like you really make this place a valuable community! Thanks for the quick reply guys.

jatar_k

6:04 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> Dumb mistake

hehe, we all make tons, that's why we post here, usually gives us some clarity

>> make this place a valuable community

ah shucks :)