Re: Warning: Supplied argument is not a valid PostgreSQL link resource

From: "Jan Gravgaard" <jan(at)klog(dot)dk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Warning: Supplied argument is not a valid PostgreSQL link resource
Date: 2003-03-01 16:48:25
Message-ID: 3e60e456$0$14528$ba624c82@nntp04.dk.telia.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I tried to change what lbayuk pointed out.

Now my functions look like this, but I still get the same warning message

<?
global $conn;

function open_conn(){

$conn_string = "host=angua.skjoldhoej.dk port=5432 dbname=fcs user=fcs
password=janfcs";
$conn = pg_connect($conn_string) or die(pg_last_error());

if (!$conn) {
echo "Kunne ikke oprette en forbindelse til PostGre databasen.";
return;
}
}

function close_conn(){
if(!pg_close($conn)) {
echo "Kunne ikke lukke forbindelsen til PostGre!";
return;
}
}

function sql_execute($query)
{
$resultat = pg_exec($conn, $query);

if(!$resultat) {
echo "Kunne ikke udfre: <em>$query</em>";
return;
}
}

function sql_execute_receive($query)
{
$resultat = pg_exec($conn, $query);
$resultat_array = array();

if(!$resultat)
{
echo "Kunne ikke udfre: <em>$query</em>";
return;
}

if (pg_numrows($resultat)>0)
{
$row = 0;
while ($item = pg_fetch_array($resultat, $row, PGSQL_ASSOC))
{
$resultat_array[] = $item;
$row++;
}
}
return $resultat_array;
}
?>

"ljb" <lbayuk(at)mindspring(dot)com> skrev i en meddelelse
news:b3p0m7$amb$1(at)news(dot)hub(dot)org(dot)(dot)(dot)
> jan(at)klog(dot)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 udfre: <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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nick Barr 2003-03-01 17:11:29 Re: Warning: Supplied argument is not a valid PostgreSQL link resource
Previous Message Jonathan Bartlett 2003-03-01 13:39:47 Re: Locking rows