ID: 39331 User updated by: guidi dot luca at gmail dot com Reported By: guidi dot luca at gmail dot com Status: Bogus Bug Type: PDO related Operating System: Linux 2.6.16.13-4-smp oSuSE10.1 PHP Version: 5CVS-2006-11-01 (snap) New Comment:
Sorry for bad reporting, but non-object is $stmt not $pdo. If i try: $pdo = new PDO("mysql:host=localhost;dbname=myDb","myUser","myPass"); $sql = 'select username from users where id = 1'; foreach ($pdo->query($sql) as $row) { // some code here } I not get the problem, so probably the issue is prepare function. Previous Comments: ------------------------------------------------------------------------ [2006-11-03 20:18:14] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php PDO class failed to instantiate (connection failed) so you don't have a PDO object. Calling methods from a non-object results in a fatal error. ------------------------------------------------------------------------ [2006-11-01 13:38:17] guidi dot luca at gmail dot com Description: ------------ PDO prepare function crash but don't display any error. i use: PDO Driver for MySQL, client library version 5.0.18 Reproduce code: --------------- $pdo = new PDO("mysql:host=localhost;dbname=myDb","myUser","myPass"); $stmt = $pdo->prepare('select username from users where id = ?'); $stmt->execute( array(123) ); $results = $stmt->fetchAll(); Expected result: ---------------- A statement execution Actual result: -------------- Fatal error: Call to a member function execute() on a non-object in /srv/www/htdocs/index.php on line 21 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39331&edit=1