PHP mysqli get_result() returns false -


when using get_result() on statement returns false instead of valid object.

function getgames() {     $ret = array();     $stmt = db::getconnection()->prepare("select * games order position desc");     $stmt->execute();     var_dump($stmt);     $result = $stmt->get_result();     while ($row = $result->fetch_assoc()) {         echo "read 1 entry";     }     return $ret; } 

the listed var_dump returns message can't extract information form:

object(mysqli_stmt)#3 (10) { ["affected_rows"]=> int(-1) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(0) ["field_count"]=> int(5) ["errno"]=> int(2006) ["error"]=> string(26) "mysql server has gone away" ["error_list"]=> array(1) { [0]=> array(3) { ["errno"]=> int(2006) ["sqlstate"]=> string(5) "hy000" ["error"]=> string(26) "mysql server has gone away" } } ["sqlstate"]=> string(5) "hy000" ["id"]=> int(1) }  

my db class looks this:

<?php class db {     private static $connection;      static function getconnection() {         if (!isset($connection) || $connection->ping()) {             $connection = new mysqli("localhost", "user", "pw", "db");             $connection->query("set names 'utf8'");         }         return $connection;     } } 

any working appreciated

ello, mate.

as can see in var_dump(), results() method returns false cause got error. error "mysql server has gone away" happens when lost connection during query.

you can read more error on mysql site.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -