2015-06-16 69 views
-2
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_fetch_row()預計參數1是資源,鑑於布爾

爲什麼?我嘗試了很多東西,但我找不到這個錯誤。

+0

看起來像是用'pg_fetch_row腳麻()'和它的返回'FALSE'(你的要求properbly失敗)。這就是你應該看看。 –

+1

在調用'pg_execute()'時發生了錯誤,但是出於某種原因,你壓制了它。 –

+0

我直接把查詢變成了de db,它起作用了! –

回答

1

刪除 「@」,看看錯誤pg_execute。如果執行沒有錯誤,使用「pg_last_error」。

相關問題