【发布时间】:2014-11-10 21:44:56
【问题描述】:
我正在尝试从“valor_premio”列中获取平均值,但出现此错误:
Warning: mysql_query() expects parameter 1 to be string, resource given in /home/u566181585/public_html/index.php on line 61 Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/u566181585/public_html/index.php on line 63
第一个回显返回:Resource id #13
$sel2 = mysql_query( "SELECT AVG(valor_premio) as avg_valor FROM novaaaa WHERE categoria='Identidade'") or (mysql_error());
echo $sel2;
$media_ident2=mysql_query($sel2);
echo $media_ident2;
$media_ident = mysql_fetch_array($media_ident2);
echo $media_ident;
怎么了?如何获得平均值?
【问题讨论】:
-
您使用了两次
mysql_query;删除一个。