php sql select*form table where name='$name' 的问题
这是代码$con=mysql_connect("localhost","me","123456");mysql_select_db("testdb",$con);mysq...
这是代码
$con = mysql_connect("localhost","me","123456");
mysql_select_db("testdb",$con);
mysql_query("set names 'gbk'",$con);
$sql = "select*form table where name='$name'";
$result = mysql_query($sql,$con);
if($result)
{
$row = mysql_fetch_array($result);
$arr = array('status'=>'success','user'=>$user,'name'=>iconv('gbk','utf-8',$row[3]),'signature'=>iconv('gbk','utf-8',$row[4]),'authentication'=>$row[5],'authenticationinfo'=>iconv('gbk','utf-8',$row[6]));
echo json_encode($arr);
}
问题是,如果$name是123,数据库有改条数据,但是却找不到,如果我把$name改成123就找到了,这是为什么?但是我现在必须使用$name变量用来查找不同用户的数据,这怎么办啊? 展开
$con = mysql_connect("localhost","me","123456");
mysql_select_db("testdb",$con);
mysql_query("set names 'gbk'",$con);
$sql = "select*form table where name='$name'";
$result = mysql_query($sql,$con);
if($result)
{
$row = mysql_fetch_array($result);
$arr = array('status'=>'success','user'=>$user,'name'=>iconv('gbk','utf-8',$row[3]),'signature'=>iconv('gbk','utf-8',$row[4]),'authentication'=>$row[5],'authenticationinfo'=>iconv('gbk','utf-8',$row[6]));
echo json_encode($arr);
}
问题是,如果$name是123,数据库有改条数据,但是却找不到,如果我把$name改成123就找到了,这是为什么?但是我现在必须使用$name变量用来查找不同用户的数据,这怎么办啊? 展开
1个回答
2017-05-27
展开全部
$sql = "select * form `table` where `name`='". $name. "'";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询