在PHP下 给MYSQL变量报错
程序员文章站
2022-06-12 21:00:07
...
在PHP上 给MYSQL变量报错
$sql = 'SET @rank =0;
. ' SELECT *FROM (SELECT @rank := @rank +1 AS rank, yb2000_event_phone, yb2000_event_point FROM yb2000_event WHERE yb2000_event_riqi = \'2012-07\' GROUP BY yb2000_event_phone ORDER BY yb2000_event_point DESC )a WHERE a.yb2000_event_phone = \'13333333333\'';
PHPMYADMIN 里正常能运行 在PHP里报错Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource 删除SET @rank =0;这一段又正常了- - 个位高人指教下
------解决方案--------------------
mysql_query只能执行一条sql语句,你上面是两条sql了
你把他们分开执行试试
------解决方案--------------------
$sql = 'SET @rank =0;';
mysql_query($sql);
$result=mysql_query(' SELECT * FROM (SELECT @rank := @rank +1 AS rank, yb2000_event_phone, yb2000_event_point FROM yb2000_event WHERE yb2000_event_riqi = \'2012-07\' GROUP BY yb2000_event_phone ORDER BY yb2000_event_point DESC )a WHERE a.yb2000_event_phone = \'13333333333\'');
mysql_query不能一次执行多条语句。分开执行。
$sql = 'SET @rank =0;
. ' SELECT *FROM (SELECT @rank := @rank +1 AS rank, yb2000_event_phone, yb2000_event_point FROM yb2000_event WHERE yb2000_event_riqi = \'2012-07\' GROUP BY yb2000_event_phone ORDER BY yb2000_event_point DESC )a WHERE a.yb2000_event_phone = \'13333333333\'';
PHPMYADMIN 里正常能运行 在PHP里报错Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource 删除SET @rank =0;这一段又正常了- - 个位高人指教下
------解决方案--------------------
mysql_query只能执行一条sql语句,你上面是两条sql了
你把他们分开执行试试
------解决方案--------------------
$sql = 'SET @rank =0;';
mysql_query($sql);
$result=mysql_query(' SELECT * FROM (SELECT @rank := @rank +1 AS rank, yb2000_event_phone, yb2000_event_point FROM yb2000_event WHERE yb2000_event_riqi = \'2012-07\' GROUP BY yb2000_event_phone ORDER BY yb2000_event_point DESC )a WHERE a.yb2000_event_phone = \'13333333333\'');
mysql_query不能一次执行多条语句。分开执行。
相关文章
相关视频
推荐阅读
-
linux CentOS 系统下如何将php和mysql命令加入到环境变量中
-
linux系统下将php和mysql命令加入到环境变量中的方法
-
解决PHP在DOS命令行下却无法链接MySQL的技术笔记
-
在PHP+Apache+MySQL环境下(windows系统),连接SQLServer数据出现“can not find driver”问题的解决办法
-
在windows iis5下安装php4.0+mysql之我见
-
php在linux下检测mysql同步状态的方法
-
在Windows XP下安装Apache+MySQL+PHP环境
-
linux CentOS 系统下如何将php和mysql命令加入到环境变量中
-
thinkphp3.2在php7下运行,出现错误"系统不支持:mysql"问题怎么解决?
-
mysql5.7在centos下编写c语言程序操作数据库时,头文件#include
报错