domingo, 26 de mayo de 2013

FC Bayern München 2 - 1 Borussia Dortmund 2013

Aquí está la liga del resumen del juego en video:

http://www.rtve.es/alacarta/videos/champions/resumen-del-borussia-1-2-bayern/1838449/

O haz clic AQUÍ

sábado, 11 de mayo de 2013

Fatal error: Call to a member function fetch_assoc() on a non-object - solved

This error appear on a code like this:

$this->open_connection();
        $result = $this->conn->query($this->query);

while($this->rows[]=$result->fetch_assoc()); /*Here was the error*/
        $result->close();


What you should do here is to add some lines of code to know where the error comes from (as described in the link: http://stackoverflow.com/questions/5121027/fatal-error-call-to-a-member-function-fetch-assoc-on-a-non-object ):

        if (!$result) {
        throw new Exception("Database Error [{$this->db_name->errno}] {$this->db_name->error}");
        }
        var_dump($result);


So the code resulted like this:

 $this->open_connection();
        $result = $this->conn->query($this->query);
        if (!$result) {
        throw new Exception("Database Error [{$this->db_name->errno}] {$this->db_name->error}");
        }
        var_dump($result);
        while($this->rows[]=$result->fetch_assoc()); /*Tengo dudas de si está bien con fetch_Assoc*/
        $result->close();
        $this->close_connection();

 In this case my error was that i was querying a column called "apellidos" (lastnames) instead of "apellido" as i had written on my code.

So, in my case was that i typed wrong the name of the column in the query. I realized that thanks to the error display:

Notice: Trying to get property of non-object in C:\xampp\htdocs\oop\db_abstract_model.php on line 38

Fatal error: Uncaught exception 'Exception' with message 'Database Error [] ' in C:\xampp\htdocs\oop\db_abstract_model.php:38 Stack trace: #0 C:\xampp\htdocs\oop\usuarios_model.php(21): DBAbstractModel->get_results_from_query() #1 C:\xampp\htdocs\oop\abm_example.php(7): Usuario->get('user@email.com') #2 {main} thrown in C:\xampp\htdocs\oop\db_abstract_model.php on line 38

 Here at the fatal error notice, i realized that there was something wrong with the query i had typed as described above.

Good luck.



 

Tags