php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39331 prepare crash without any error
Submitted: 2006-11-01 13:38 UTC Modified: 2006-11-03 23:37 UTC
From: guidi dot luca at gmail dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2006-11-01 (snap) OS: Linux 2.6.16.13-4-smp oSuSE10.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: guidi dot luca at gmail dot com
New email:
PHP Version: OS:

 

 [2006-11-01 13:38 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-03 20:18 UTC] iliaa@php.net
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-03 23:37 UTC] guidi dot luca at gmail dot com
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 09:01:28 2025 UTC