Currently I'm working on a microblog just to get familiar with PHP MySQL.
I have a pretty big problem though.
Here's the php code:
function get_all_users(){
$query = "SELECT * FROM ".$this->prefix."users";
if ($stmt = $this->prepare($query)){
$stmt->execute();
$users_array = array();
$stmt->bind_result($id, $username, $password, $realname, $email);
while ($stmt->fetch()){
$oneuser = array('id'=>$id, 'user'=>$username, 'name'=>$realname, 'email'=>$email);
array_push($users_array, $oneuser);
}
$stmt->close();
return $users_array;
} else {
echo "get_all_users() encountered a fatal error: " . $this->error;
exit();
}
}
Note that the above function is under a class that extends mysqli.
The error is:
Warning: mysqli::prepare() [mysqli.prepare]: Couldn't fetch MicrobloggingDatabase in C:\xampp\htdocs\microblog\includes.php on line 121
Warning: MicrobloggingDatabase::get_all_users() [microbloggingdatabase.get-all-users]: Couldn't fetch MicrobloggingDatabase in C:\xampp\htdocs\microblog\includes.php on line 132
get_all_users() encountered a fatal error:
Also, when i try to close the database after generating the page, i get this warning:
Warning: mysqli::close() [mysqli.close]: Couldn't fetch MicrobloggingDatabase in C:\xampp\htdocs\microblog\admin.php on line 107
any ideas?