Gigg
Gigg

Reputation: 1049

mysql query issue

I have a small issue:

I recieve few paramaters via ajax and make a sql query. Simple, but this query has some special characters(brazilian) and my query looks like that(as I've made a echo):

SELECT neigh 
FROM address_bd 
WHERE 
  state ="AL" 
  AND city ="Maceió" 
GROUP BY neigh 
ORDER BY neigh ASC

and in the script is:

$sql = "
  SELECT neigh 
  FROM address_bd 
  WHERE state =\"$state\" 
    AND city =\"$city\" 
  GROUP BY neigh 
  ORDER BY neigh ASC
  ";

Running it in phpmyadmin return the correct result, but in the script gives 0 results. My sql row has utf8_general_ci. Does anyone have any idea? Thank you.

AND here comes the response:

SET character_set_client = utf8;

This resolved the issue. Thank you all and especialy to Inca for sending the link. Thank you again

Upvotes: 0

Views: 58

Answers (2)

Olli
Olli

Reputation: 752

Maybe try this:

$sql = "SELECT neigh FROM address_bd WHERE state = '$state' AND city = '$city' GROUP BY neigh ORDER BY neigh ASC";

If it still does not work add this after mysql_query function

print mysql_error();

and tell here the error message content.

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157838

you should have mysql_set_charset(charset); or corresponding operator for your database driver placed right after your database connect operator.

and charset should represent actual charset of your HTML pages.

Upvotes: 1

Related Questions