mySQL: problem searching for text string rather than number
Posted: Tue Jul 30, 2002 7:01 pm
Hello everyone,
When I search for an article based on a key (called $url_key because it will be passed as an URL parameter) like this:
This works fine if the key is only a number, but as soon as there is a letter in the key (it becomes a string) this no longer works.
I've found a way to fix this using 'like' instead of '=':
But being curious I was wondering why exactly this happens. Any pointers?
Thanks, Toro
When I search for an article based on a key (called $url_key because it will be passed as an URL parameter) like this:
Code: Select all
$query = "select * from articles where url_key = ".$url_key;I've found a way to fix this using 'like' instead of '=':
Code: Select all
$query = "select * from articles where url_key like '%".$url_key."%'";Thanks, Toro