Odd mysql/php behavior with LIKE clause

Odd mysql/php behavior with LIKE clause

am 16.08.2006 16:37:34 von RobbGMelenyk

The following query:

SELECT rownum from(SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT
@rownum:=0) r,
(SELECT Application
FROM application_list_1.application_data_table a ORDER BY Application
asc ) t) s
WHERE Application like '$app%' order by Application asc limit 1

where $app is my search query passed in from an html form. This query
is run in a PHP script. I run it with the following code:

$row = mysql_fetch_assoc($sql);
return $row['rownum'];

This works 100% fine EXCEPT when I pass 'a' or 'A' to the query from
the html form. Every other letter or string works just fine except the
'a' or 'A'. Also, I can run this query within MySQL query browser with
'a' or 'A' and get valid results.

I'm totally confused. What is the problem with the 'a'? Encoding?

Re: Odd mysql/php behavior with LIKE clause

am 16.08.2006 17:09:46 von RobbGMelenyk

Found it! There was a problem further on in my code producing the
error. Sorry to bother anyone!


RobbGMelenyk@gmail.com wrote:
> The following query:
>
> SELECT rownum from(SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT
> @rownum:=0) r,
> (SELECT Application
> FROM application_list_1.application_data_table a ORDER BY Application
> asc ) t) s
> WHERE Application like '$app%' order by Application asc limit 1
>
> where $app is my search query passed in from an html form. This query
> is run in a PHP script. I run it with the following code:
>
> $row = mysql_fetch_assoc($sql);
> return $row['rownum'];
>
> This works 100% fine EXCEPT when I pass 'a' or 'A' to the query from
> the html form. Every other letter or string works just fine except the
> 'a' or 'A'. Also, I can run this query within MySQL query browser with
> 'a' or 'A' and get valid results.
>
> I'm totally confused. What is the problem with the 'a'? Encoding?