pg_fetch_row() 期望参数 1 是资源,给定布尔值


pg_fetch_row() expects parameter 1 to be resource, boolean given

function data_volcan($pg, $id_ciudad) {
    $arr = array();
    $anno = 1990;
    $i=0;
    $ret = array();
    while($anno < 2016){
        $newString1 = $anno.'-01-01 00:00:00';
        $newString2 = $anno.'-12-31 23:59:59';
        $string = "SELECT count(evento.id_evento) FROM evento,ciudad_evento WHERE evento.inicio > $1 and evento.inicio > $2 and evento.id_evento = ciudad_evento.id_evento and ciudad_evento.id_ciudad = $3 and evento.tipo = 'volcan'";        
        array_push($arr,$newString1,$newString2,$id_ciudad);        
        $result = pg_prepare($pg,"query_data_volcan".$i,$string);
        $result = @pg_execute($pg, "query_data_volcan".$i,$arr);
        $ans = array();
        while ($r = pg_fetch_row($result)) {
           $arraytemp = array();
           array_push($arraytemp,$r["0"]);
           array_push($ans,$arraytemp);
           $ret[$i] = $ans[0];
        }
        $i++;
        $anno++;        
    }
    return $ret;
}

此错误在行while ($r = pg_fetch_row($result))

为什么?我尝试了很多东西,但我找不到错误。

删除"@",并在pg_execute中看到错误。 如果执行没有错误,请使用"pg_last_error"。

相关文章: