MySQL using Object-Oriennted

In this tutorial we learn Object oriented way to create MySQL connection.Before we can access data in the MySQL database, we need to be able to connect to the server.  
 
<?php
$servername = "localhost";
$username = "your username";
$password = "
your password";

// Create connection$conn = new mysqli($servername, $username, $password);

// Check connection if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
 
?>
 
Happy Coding... 

0 Comments