Re: Cannot create statement handler

From: Date: Mon, 17 Nov 2008 14:35:51 +0000
Subject: Re: Cannot create statement handler
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-283356@lists.php.net to get a copy of this message
Thodoris wrote:
I was wondering if anyone sees something I am bypassing: I have this sample code that works in another server: <?php function getClientFullName($dbh,$id){ // die(var_dump($dbh)); $sql = "SELECT * FROM Clients WHERE Id=".$id; // die(print $sql); $sthr = $dbh->query($sql); // die(var_dump($sthr)); $res = $sthr->fetch(PDO::FETCH_ASSOC); return $res['Name']; } try { $dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 'root', '', array(PDO::ATTR_PERSISTENT => false)); $sql = "SELECT * FROM Contracts"; $sth = $dbh->query($sql); print "<pre>"; while($res = $sth->fetch(PDO::FETCH_ASSOC)) {
       $name = getClientFullName($dbh,$res['ClientId']);
       print $name."<br>";
} } catch (Exception $e) { print $e->getMessage(); } ?> but in my case I can't make it work on my own server. I have removed both PHP and apache and compiled everything for source just to make sure that I will avoid possible problems using rpm. It seems that if I dump $sthr it returns false. Although if I print the query and use it directly it works fine. Apache 2.2.10 PHP 5.2.6 Linux EL5 I've posted this some days ago but none had any idea about this. Do think this could be a bug?
obvious but: do a phpinfo() and check PDO is installed on the failing server check db is on the failing server check mysql is running on the failing server check username and pass are correct for db check username and pass combo can access via localhost

« previous php.general (#283356) next »