Re: Warning: Supplied argument is not a valid PostgreSQL link resource - Mailing list pgsql-general

From ljb
Subject Re: Warning: Supplied argument is not a valid PostgreSQL link resource
Date
Msg-id b3p0m7$amb$1@news.hub.org
Whole thread Raw
List pgsql-general
jan@klog.dk wrote:
> Hi there
>
> I get the above mentioned warning when I execute php that contacts the
> postgre database.
>
> I use the following functions to connect to db
>
> Some of the text is in danish :-)
> ...
>
>     function sql_spoerg_og_faa_svar($dbcon, $query)
>     {
>       $resultat = pg_exec($dbcon, $query);
>       $resultat_array = array();
>       if(!$resultat)
>       {
>         echo "Kunne ikke udføre: <em>$query</em>";
  =====>
>       }
>       while($raekke = pg_fetch_array($resultat))
>       {
>         $resultat_array[] = $raekke;
>       }
>           return $resultat_array;
>       }
>
> Anyone who knows whats wrong ?

You are falling through the error and continuing with a bad result handle
up there where I put =====>. Needs a return or something.

pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: multiple conditions in same plpglsql IF block
Next
From: Jean-Christian Imbeault
Date:
Subject: Re: Locking rows