Jonathan Heaton - 2009-08-24 14:37:28
Fatal error: Call to a member function fetch_row() on a non-object in C:\wamp\www\convert\MySQL_to_PHP.class.php on line 81.
My setup on Windows Vista:
WampServer 2.0i [07/11/09]
Includes :
- Apache 2.2.11
- MySQL 5.1.36
- PHP 5.3.0
I am an experienced programmer but I have only used PHP for 1 month.
Your script is exactly what I am looking for. However I got this error message. I have tried to solve the problem by writing a simple program to do something similar. However I did not get the same error message.
public function CreateClassesFiles(){
$loop = $this->connection->query("SHOW tables FROM ".$this->dbname."");
while($row = $loop->fetch_row()){
$this->classe_name[$this->num_of_tables]['name'] = $row[0]; //get the name of the table/class
$this->classe_name[$this->num_of_tables]['total_vars'] = 0;
$loop2 = $this->connection->query("SHOW columns FROM ". $row[0]);
$j = 0;
HERE IS PROBLEM (line 81) while ($row2 = $loop2->fetch_row()){
$this->classe_variables[$j]['var_name'] = $row2[0];
$this->classe_variables[$j]['lenght']= $row2[1];
$row2[3] == "PRI" ? $this->classe_variables[$j]['key'] = 1 : $this->classe_variables[$j]['key'] = 0;
$this->num_of_total_variables += 1;
$this->classe_name[$this->num_of_tables]['total_vars'] += 1;
$j++;
}
$this->CreatFiles();
$this->num_of_tables += 1;
}
$this->CreateDataBaseClass();
}
Thanks
Jonathan Heaton