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

时间:2015-03-26 23:12:10   收藏:0   阅读:359

$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");
就不行了

 

$res = mysql_query("select songer_name from song_tab where song_name =‘$temp2‘");

     或 ‘{$temp2‘}’都可以

原文:http://www.cnblogs.com/xihong2014/p/4370308.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!