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

时间:2015-06-16 20:12:30

标签: php postgresql

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))

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

1 个答案:

答案 0 :(得分:1)

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