From: | "Nick Barr" <jnb(at)wb9(dot)webbased(dot)co(dot)uk> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Warning: Supplied argument is not a valid PostgreSQL link resource |
Date: | 2003-03-01 17:11:29 |
Message-ID: | 8F4A22E017460A458DB7BBAB65CA6AE5027B75@webbased9.wb9.webbased.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
> function sql_execute($query)
> {
> $resultat = pg_exec($conn, $query);
>
> if(!$resultat) {
> echo "Kunne ikke udføre: <em>$query</em>";
> return;
> }
> }
You are missing the global $conn in the function. You either need to feed it in as a parameter or reference it as a global variable.
function sql_execute($conn, $query)
{
$resultat = pg_exec($conn, $query);
if(!$resultat)
{
echo "Kunne ikke udføre: <em>$query</em>";
return;
}
}
OR
function sql_execute($query)
{
global $conn;
$resultat = pg_exec($conn, $query);
if(!$resultat)
{
echo "Kunne ikke udføre: <em>$query</em>";
return;
}
}
This is the same for the sql_execute_receive, conn_close and any other function that references $conn. PHP does not automatically include global variables in the functions scope.
I currently set $conn to be a global variable (i.e. declared outside the function) and use the global $conn method to get it into scope with the function.
Hope that's a little clearer.
Nick Barr
From | Date | Subject | |
---|---|---|---|
Next Message | Detlef Jockheck | 2003-03-01 18:54:31 | Re: automatic creation of oid |
Previous Message | Jan Gravgaard | 2003-03-01 16:48:25 | Re: Warning: Supplied argument is not a valid PostgreSQL link resource |