ToonMariner Posted November 16, 2009 Share Posted November 16, 2009 Hey guys n gals... At a bit of a loss on this one... PHP on server is 5.1.6 (have 5.3 local) and PDO_MYSQL support is available on server... Get no errors connecting to the mysql database but the queries I am running return nothing... tried really simple stuff that I know data exists for in the correct tables like <?php $db = new PDO ('xxxxx'); $qry = " SELECT `user_id`, `username`, `user_level` FROM `users` WHERE `username` = :username "; $result = $this->prepare ( $qry ); $result->bindParam ( ':username' , 'toonmariner' , PDO::PARAM_STR ); $result->execute (); var_dump ( $result->errorInfo()); echo '<br />Rowcount: ' . $result->rowCount () . '<br />'; if ( $result->rowCount () == 0 ) { echo 'NO rows.'; return NULL; } else { return $result->fetchAll (PDO::FETCH_ASSOC); } ?> On local machine I get the expected results [code] array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL } Rowcount: 1 Array ( [0] => Array ( [user_id] => 1 [username] => toonmariner [user_level] => 1 ) ) where as live server yields... array(1) { [0]=> string(5) "00000" } Rowcount: 0 NO rows. Can any suggest some tasks to check what the hell is going on? Database structure on dev and live server are identical as is the contents. Link to comment https://forums.phpfreaks.com/topic/181738-solved-pdo-help/ Share on other sites More sharing options...
Vebut Posted November 16, 2009 Share Posted November 16, 2009 Does that user exist in the public database? Link to comment https://forums.phpfreaks.com/topic/181738-solved-pdo-help/#findComment-958559 Share on other sites More sharing options...
ToonMariner Posted November 16, 2009 Author Share Posted November 16, 2009 yes... as an update.. I call var_dump ( debug_backtrace () ); after that code and when I run this on the server it prints out the array multiple times in a loop (which will explain why I'm getting mysql has gone away) but I end the script directly after the var_dump so I'm a little concerned as to why this cyclical call is going on... Link to comment https://forums.phpfreaks.com/topic/181738-solved-pdo-help/#findComment-958590 Share on other sites More sharing options...
RichardRotterdam Posted November 16, 2009 Share Posted November 16, 2009 $result = $this->prepare ( $qry ); shouldn't "$this" be "$db" ? Link to comment https://forums.phpfreaks.com/topic/181738-solved-pdo-help/#findComment-958598 Share on other sites More sharing options...
ToonMariner Posted November 16, 2009 Author Share Posted November 16, 2009 sorry its my copy and paste - when ever you see $this replace with $db.... Link to comment https://forums.phpfreaks.com/topic/181738-solved-pdo-help/#findComment-958600 Share on other sites More sharing options...
ToonMariner Posted November 16, 2009 Author Share Posted November 16, 2009 OK don't ask me why BUT - there is an array returned with the results but rowCount() is always returning 0!!! oh well Link to comment https://forums.phpfreaks.com/topic/181738-solved-pdo-help/#findComment-958615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.