You are here: php 5 call to member function prepare() on a non object error « PHP Programming Language « IT news, forums, messages
php 5 call to member function prepare() on a non object error

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация