Re: PDO Error

From: Date: Fri, 15 Jul 2005 09:22:16 +0000
Subject: Re: PDO Error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-218731@lists.php.net to get a copy of this message
> Hi. When using this example from > http://netevil.org/talks/index.php?t=pdo&s=20, the site of > pdo's author I > have this error: > > Fatal error: Call to a member function fetchAll() on a non-object in > /www/home/testes/pdo_my1.php on line 17 > > Object creation : > $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', > 'pass'); > $stmt = $dbh->query("SELECT * FROM foo"); Here I think $stmt is NOT an object. $stmp should be RESOURCE or boolean value most likely. So it should be $rows=$dbh->fetchAll(); > $rows = $stmt->fetchAll(); > $count = count($rows); > foreach ($rows as $row) { > print_r($row); > } > $stmt = null; > > Wht's wrong with the example? > > Greetings > holografix -- Regards Georgi Ivanov

« previous php.general (#218731) next »