Posted by Jerry Stuckle on 01/03/08 18:50
Rowan wrote:
>
> 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)){
You never set $dbh here, so this has to be true.
> $dbh = self::cxn();
>
Obviously, self::cxn() is not returning an object.
}
> 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>
>
>
Not enough code to tell what might be the problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|