Posted by Rowan on 01/03/08 18:00
When I run a small test script I get the following error.
___________________________
PHP Fatal error: Call to a member function prepare() on a non-object
in /usr/local/lib/php5/pg_connect.php on line 73
<snippet_____________________>
public static function db_update($sql) {
$str_check = explode(" ", $sql);
if($str_check[0] == "INSERT") {
if (!isset($dbh)){
$dbh = self::cxn();
}
line 73 ---> $stmnt = $dbh->prepare($sql);
$stmnt->execute();
return 1;
}
</_____________________________snippet>
this is part of a class called db_cxn which is being called by the
following statement from a separate class.
-->if ($cxn->db_update($sql)){
whats weird is there is a previous call to a very similar function
below which works fine. can anyone point me in the right direction ?
fyi both objects are created as such --->$dbh = self::cxn(); where
$dbh is private static.
<snippet_____________________>
$stmnt = $dbh->prepare($sql);
$stmnt->execute();
$result = $s<tmnt->fetchAll();
return $result;
</_____________________________snippet>
Navigation:
[Reply to this message]
|