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?

--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to