我有这个疑问:PHP MYSQL SET给出错误while循环
$result2 = mysql_query("SET @total=0;
SELECT *,
@total:= @total+ `companyearned` AS `total`
FROM `recordedhours` WHERE `group` = '$uid'
ORDER BY `unixdate` DESC, `idnum` DESC
LIMIT $from, $max_results");
while ($rowb = mysql_fetch_array($result2)) {
//DO STUFF
}
但SET @总= 0;使得while行给我一个错误: 警告:mysql_fetch_array():提供的参数不是有效的MySQL结果资源 查询在phpmyadmin中正常工作,并且在没有SET @ total = 0的情况下工作正常;
您不能在调用'mysql_query()'时给出多个查询。 – Barmar 2013-04-21 06:10:05
Look @ http://stackoverflow.com/q/12274964/1288198 – 2013-04-21 06:12:28