PHP头条
热点:

php查询mysql数据库查询条件替中文字符串变量时无法查询


php查询mysql数据库 查询条件为中文字符串变量时无法查询
$temp2 ='十年';
mysql_query("SET NAMES GBK");
$res = mysql_query("select songer_name from song_tab where song_name ='十年'");
可以查询出结果 
但是

$temp2 ='十年';
mysql_query("SET NAMES GBK");
$res = mysql_query("select songer_name from song_tab where song_name =$temp2");
就不行了 请问怎么解决啊
------解决方案--------------------
$temp2 左右两边加单引号,最好先addslashes()。
------解决方案--------------------
引号!
$res = mysql_query("select songer_name from song_tab where song_name ='$temp2'");

www.phpzy.comtrue/phprm/12939.htmlTechArticlephp查询mysql数据库查询条件替中文字符串变量时无法查询 php查询mysql数据库 查询条件为中文字符串变量时无法查询 $temp2='十年'; mysql_query("SETNAMESGBK"); $res=mysql_query("selectsonger_namefromsong_...

相关文章

相关频道:

PHP之友评论

今天推荐