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
globalvariable.
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
automaticallyinclude 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
getit into scope with the function.
Hope that's a little clearer.
Nick Barr