Forum Moderators: coopster

Message Too Old, No Replies

problem with MySql Query

i'm using "mysql_real_escape_string()"

         

numnutz

2:01 pm on Aug 26, 2005 (gmt 0)

10+ Year Member



Hi I am having a bit of trouble with the following MySql statement:

$test = 'A';

$query = sprintf("select DISTINCT location, count(*) FROM transport WHERE location LIKE '%s' GROUP BY location", mysql_real_escape_string($test));

echo $query ;

$result = mysql_query($query,$db);

if I enter the query in full text it works fine, the query is correctly echoed in the variable $query.

If however I use the above code snippet I get nothing returned in $result although there is no error, and there is definately entries in the database beginning with

please tell me where I am going wrong

thanks in advance

// sorry about this I am having a brainless moment I forgot to put in the wild card in the variable $test should be $test = 'A%';

nn :)

ergophobe

3:52 pm on Aug 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome numnutz

If you take the query that is echoed by your script and run it directly in your MySQL client (command line or similar), what happens?