The selectMsg function can be output, but it won't work in the following cities. check whether it is a problem such as the table name. the field is also utf8, and the query can also be solved. After connecting to the database, add the following code {code ...}
$ Con = mysql_connect ("localhost", "root", "root"); // $ dbname = "weixin"; function selectMsg ($ str) {$ rows = array (); $ msgArr = array (); $ like = array (); $ arr = array (); $ SQL = "SELECT * FROM weixin. weixin_msg WHERE FIND_IN_SET ('". $ str. "', Title)"; $ result = mysql_query ($ SQL); while ($ rows = mysql_fetch_array ($ result, MYSQL_ASSOC) {$ msgArr [] = $ rows ;} if (! Empty ($ msgArr) {return $ msgArr;} else {$ sqlstr = "SELECT * FROM weixin. weixin_msg WHERE Title LIKE '% ". $ str. "% 'order by id desc"; $ like = mysql_query ($ sqlstr); while ($ arr = mysql_fetch_array ($ like, MYSQL_ASSOC )) {$ msgArr [] = $ arr;} return $ msgArr;} function cityName ($ keyword) {$ SQL = "SELECT * FROM weixin. weixin_cityname WHERE FIND_IN_SET ('". $ keyword. "', CityNameCn)"; $ result = mysql_fetch_array (mysql_query ($ SQL), MYSQL_ASSOC); print_r ($ result);} cityName ("Beijing "); $ res = selectMsg ("123"); echo"";print_r($res);
The selectMsg function can be output,
However, the following cities won't work. Check whether the table name is a problem or not. The field is also utf8.
This query can also be performed.
Solution: add the following code after connecting to the database
Header ("Content-Type: text/html; charset = UTF-8"); // connect to the database $ con = mysql_connect ("localhost", "root", "root "); mysql_query ("set character set 'utf8'"); // read database mysql_query ("set names 'utf8'"); // write DatabaseOne answerRun the SQL command directly in the database.
Similar
Select * from city where FIND_IN_SET (city_name, '2013 ');