在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不能一次执行多条语句。分开执行。