Establish connecting between php and MySQL #

Before doing anything to the database we need to make the connection between php and MySQL. Once the connection has been made then we can send the SQL query to database.

We are making CRUD operation it means we will need send at least 4 sql query.

  • 1st Query : Create
  • 2nd Query : Read
  • 3rd Query : Update
  • 4th Query : Delete
db.php
    <?php
        $server = "localhost";
        $user = "root";
        $pass = "";

        $con = new mysqli($server, $user, $pass, "crud");

        if($con->connect_error){
            die("Connection Error");
        }else{
            echo "Connected Successfully";
        }

    ?>