It's late, so maybe I'm missing something simple, but here goes...
I have a php file that has this code:
function getTodaysImages() {
$query = "SELECT * FROM MyTable where date_last_viewed = cast('" .
date("j
F Y") . "' as date);";
//echo($query . "<hr>");
$result = pg_query($connection, $query) or die("Error in query:
$query. "
. pg_last_error($connection));
return $result;
}
the $connection object is declared in a previous function with the global
keyword. My understanding is that it should then be available to subsequent
functions. When I run my code, I get this error:
Warning: pg_exec(): supplied argument is not a valid PostgreSQL link
resource in /home/httpd/htdocs/myfolder/db.php on line 23
Line 23 happens to be the pg_query line. If I take this code and put it
directly on my web page (instead of through a function in an include file),
I get no errors. So it would appear I have a variable scoping issue. The
resources I have thus far (including Google) haven't been too helpful - I
haven't found that "magic" search term yet. (searching on the error returns
a crap load of files which suffer from the same error, rather than a
discussion of the error - found one discussion, but the answer didn't seem
to apply and didn't fix it anyways.. )
Anyone have any tips? I am new to PHP and Postgresql (finally got postgres
running yesterday...), and am at the beginning of the learning process with
both...
Thanks bunchs for any input.
Shawn