php中mysql查询语句,变量的值无法用于mysql表达式中
<?php$con=mysql_connect("XXXXX","XXXXXXX","XXXXXX");mysql_select_db("XXXXXX");mysql_c...
<?php
$con=mysql_connect("XXXXX", "XXXXXXX", "XXXXXX");
mysql_select_db("XXXXXX");
mysql_close($con);
$a="accountname";
$result1=mysql_query("SELECT * FROM userinformation WHERE Accountname=$a");
$row1=mysql_fetch_row($result1);
mysql_close($con);
?>
脚本运行后报错:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/51/11444851/html/script/likepoints_increase.php on line 27
但是将语句
$result1=mysql_query("SELECT * FROM userinformation WHERE Accountname=$a");
更改为
$result1=mysql_query("SELECT * FROM userinformation WHERE Accountname=‘accountname'");
后,脚本运行却正常
数据库无损坏,字段类型
Accountname varchar(50)
utf8_bin 展开
$con=mysql_connect("XXXXX", "XXXXXXX", "XXXXXX");
mysql_select_db("XXXXXX");
mysql_close($con);
$a="accountname";
$result1=mysql_query("SELECT * FROM userinformation WHERE Accountname=$a");
$row1=mysql_fetch_row($result1);
mysql_close($con);
?>
脚本运行后报错:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/51/11444851/html/script/likepoints_increase.php on line 27
但是将语句
$result1=mysql_query("SELECT * FROM userinformation WHERE Accountname=$a");
更改为
$result1=mysql_query("SELECT * FROM userinformation WHERE Accountname=‘accountname'");
后,脚本运行却正常
数据库无损坏,字段类型
Accountname varchar(50)
utf8_bin 展开
2个回答
展开全部
<?php
$con=mysql_connect("XXXXX", "XXXXXXX", "XXXXXX");
mysql_select_db("XXXXXX");
mysql_close($con);
$a="accountname";
$sql="SELECT * FROM userinformation WHERE Accountname='".$a."'";
$result1=mysql_query($sql);
$row1=mysql_fetch_row($result1);
mysql_close($con);
?>
$con=mysql_connect("XXXXX", "XXXXXXX", "XXXXXX");
mysql_select_db("XXXXXX");
mysql_close($con);
$a="accountname";
$sql="SELECT * FROM userinformation WHERE Accountname='".$a."'";
$result1=mysql_query($sql);
$row1=mysql_fetch_row($result1);
mysql_close($con);
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询