Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php pg_fetch_row()期望参数1是给定的布尔资源 功能数据\u volcan($pg,$id\u ciudad){ $arr=array(); $anno=1990; $i=0; $ret=array(); 而($anno1和evento.ini>2,evento.id\u evento=ciudad\u evento.id\u evento和ciudad\u evento.id\u ciudad=$3和evento.tipo='volcan'; 数组推送($arr、$newString1、$newString2、$id\u ciudad); $result=pg\u prepare($pg,“查询数据\u volcan”。$i,$string); $result=@pg\u execute($pg,“查询数据\u volcan”。$i,$arr); $ans=数组(); 而($r=pg_fetch_row($result)){ $arraytemp=array(); array_push($arraytemp,$r[“0”]); 阵列推送($ans,$arraytemp); $ret[$i]=$ans[0]; } $i++; $anno++; } 返回$ret; }_Php_Postgresql - Fatal编程技术网

Php pg_fetch_row()期望参数1是给定的布尔资源 功能数据\u volcan($pg,$id\u ciudad){ $arr=array(); $anno=1990; $i=0; $ret=array(); 而($anno1和evento.ini>2,evento.id\u evento=ciudad\u evento.id\u evento和ciudad\u evento.id\u ciudad=$3和evento.tipo='volcan'; 数组推送($arr、$newString1、$newString2、$id\u ciudad); $result=pg\u prepare($pg,“查询数据\u volcan”。$i,$string); $result=@pg\u execute($pg,“查询数据\u volcan”。$i,$arr); $ans=数组(); 而($r=pg_fetch_row($result)){ $arraytemp=array(); array_push($arraytemp,$r[“0”]); 阵列推送($ans,$arraytemp); $ret[$i]=$ans[0]; } $i++; $anno++; } 返回$ret; }

Php pg_fetch_row()期望参数1是给定的布尔资源 功能数据\u volcan($pg,$id\u ciudad){ $arr=array(); $anno=1990; $i=0; $ret=array(); 而($anno1和evento.ini>2,evento.id\u evento=ciudad\u evento.id\u evento和ciudad\u evento.id\u ciudad=$3和evento.tipo='volcan'; 数组推送($arr、$newString1、$newString2、$id\u ciudad); $result=pg\u prepare($pg,“查询数据\u volcan”。$i,$string); $result=@pg\u execute($pg,“查询数据\u volcan”。$i,$arr); $ans=数组(); 而($r=pg_fetch_row($result)){ $arraytemp=array(); array_push($arraytemp,$r[“0”]); 阵列推送($ans,$arraytemp); $ret[$i]=$ans[0]; } $i++; $anno++; } 返回$ret; },php,postgresql,Php,Postgresql,当($r=pg\u fetch\u row($result)) 为什么??我尝试了很多东西,但我找不到错误。删除“@”,并在pg_execute中看到错误。如果执行时没有错误,请使用“pg_last_error” 看起来pg_fetch_row()出现了问题,并且返回了false(您的请求很可能失败)。这就是您应该研究的。错误发生在您对pg_execute()的调用中,但出于某种奇怪的原因,您已将其抑制。我直接在de db中进行了查询,结果成功了!这些是错误警告:pg_prepare()希望参数

当($r=pg\u fetch\u row($result))


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

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

看起来
pg_fetch_row()
出现了问题,并且返回了
false
(您的请求很可能失败)。这就是您应该研究的。错误发生在您对
pg_execute()
的调用中,但出于某种奇怪的原因,您已将其抑制。我直接在de db中进行了查询,结果成功了!这些是错误警告:pg_prepare()希望参数3是字符串,数组在第327行的/var/www/html/grupo20/entrega4/funcion01.php中给出警告:pg_execute():查询失败:错误:第328行的/var/www/html/grupo20/entrega4/funcion01.php中不存在prepared语句“Query_data\u volcan0”
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;
}