您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php执行mysql语句有关问题

2024/4/13 14:31:16发布14次查看
php执行mysql语句问题
$id=1; 这个是确定没问题
这个执行就错误
$sql=update admin set pass='$pass1' where id=$id;;
$mysql=new mysqlhelper();
$count=$mysql->query($sql);
$mysql.close();
you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near '' at line 1
这个执行就正确
$sql=update admin set pass='$pass1' where id=1;;‘
$mysql=new mysqlhelper();
$count=$mysql->query($sql);
$mysql.close();
分享到:
------解决方案--------------------
打印出 $sql 就知道了
------解决方案--------------------
引用:$id=1; 这个是确定没问题
这个执行就错误
$sql=update admin set pass='$pass1' where id=$id;;
$mysql=new mysqlhelper();
$count=$mysql->query($sql);
$mysql.close();
you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near '' at line 1
这个执行就正确
$sql=update admin set pass='$pass1' where id=1;;‘
$mysql=new mysqlhelper();
$count=$mysql->query($sql);
$mysql.close();
红色部分有个分号
------解决方案--------------------
$sql=update admin set pass='.$pass1.' where id=$id;; 改成这个试试
------解决方案--------------------
2l正解 不需要加分号   版大说的是解决此类问题的共通办法:查询遇到问题 先打印出sql语句检查一下 十有八九就明白了./
------解决方案--------------------

测试了下,还真是这个问题
------解决方案--------------------
$sql=update admin set pass='.$pass1.' where id=.$id;
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product