php - Properties not found in OOP


I got Fatal error: Class 'mysqli' not found in /config/mySQL_class.php on line 19 I have test my code but I can't seem to find a solution to my problem, I'm just a beginner programmer who started to try OOP yesterday. Any Ideas?


class Database

    public $data;

    public $mysqli;

    public function __construct($host, $username, $password, $database){

        $this->mysqli = new mysqli($host, $username, $password, $database);


            echo "Error: Could not connect to database.";



    public function __destruct(){



    public function read(){

    $sql = "SELECT * FROM `user` ";
    $result = $this->mysqli->query($query);
    $num_result = $result->num_rows;




            } else {

                return $this->data;






$obj=new Crud("localhost","root","","crud");

    <table width="500" border="1" cellpadding="5">
        <th width="16" scope="row">id</th>
        <td width="95">name</td>
        <td width="140">email</td>
        <td width="104">address</td>
         <td width="71">Mobile</td>

        foreach($obj->data as $val){

            <td scope="row"><?php echo $id; ?></td>
            <td><?php echo $name; ?></td>
            <td><?php echo $email; ?></td>
            <td><?php echo $address; ?></td>
            <td><?php echo $mob; ?></td>
             <td><a href="edit.php?id=<?php echo $id; ?>">edit</a>|<a href="delete.php?id=<?php echo $id; ?>">Delete</a></td>




It's a comon error when the MySQLi extension isn't installed on your server.

To check if MySQLi extension is available, try this:

if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
    echo 'MySQLi extension is missing!';
} else {
    echo 'MySQLi extension is installed!';

To install the MySQLi extension, follow this instructions.

It is also possible that you have the MySQLi extension installed, but commented in the php.ini file. Open php.ini and check if isn't commented. If so, uncomment and restart apache server.

People are also looking for solutions to the problem: php - Arabic text not storing in the mysql data base?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.