Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-04-2009, 08:03 PM   PM User | #1
animedude123
New to the CF scene

 
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
animedude123 is an unknown quantity at this point
Numbers + Letters Match in WHERE clause

Hey,

Right now I have this as my mysql query:

Code:
SELECT * FROM rofl WHERE id='13159' LIMIT 1
This returns the correct table. My question is though if I add a letter to it like this:

Code:
SELECT * FROM rofl WHERE id='13159f' LIMIT 1
Why does it still return the row with the column id 13159? Its like it is ignoring the "f" and still returning the row as if it wasn't there.

If I take out all the numbers and just have it as "f" it says there is no row.

If I take out the "f" and replace it with a "5" or something, it also says there is no row.

Any ideas on why numbers + letters are acting this way in the WHERE clause, and how I should fix it?

Thanks in advance for any help!
animedude123 is offline   Reply With Quote
Old 04-04-2009, 08:17 PM   PM User | #2
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,712
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
If your id column is numeric, the value on the right side of the = is parsed as a number, up to the first non-numeric digit. The "f" or any other non-numeric character you put there is a stop character.

If you are only expecting a number, you either need to validate that it only contains numeric digits or you need to cast it as an integer.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

Last edited by CFMaBiSmAd; 04-04-2009 at 08:33 PM.. Reason: fixed case -> cast
CFMaBiSmAd is offline   Reply With Quote
Old 04-04-2009, 08:25 PM   PM User | #3
animedude123
New to the CF scene

 
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
animedude123 is an unknown quantity at this point
Ok, thanks

I'll just have to validate it.
animedude123 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:04 AM.


Advertisement
Log in to turn off these ads.