0
我试图计算我的数据库的“阶段”表中的“容量”列的总计。这是我使用的代码:使用PHP的SQL SUM函数
$result = mysql_query('SELECT SUM(capacity) AS total_capacity FROM stages');
$row = mysql_fetch_assoc($result);
$sum = $row['total_capacity'];
但这个错误被称为:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in E:\xampp-portable\htdocs\Festival\Admin\Reports\index.php on line 11
任何解决方案?
可能的重复[mysql_fetch_array()期望参数1为资源,布尔值在select中指定](http://stackoverflow.com/a/11674313/250259) –
在您的mysql_query调用后检查mysql_error的结果。你的查询有问题。 –
我已经测试了后台程序中的sql代码,它工作正常。 – JamsHack