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?

is there any database called MicrobloggingDatabase ?

Sorry i was being stupid. MicrobloggingDatabase is a class that extends mysqli that i created. It however, doesn't connect to MySQL upon __construct(). It connect when it's start()'ed. I forgot to do that.

*Facepalm*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.