CONTACT @ Skype : rajdimdung   |   call : +977 9841813550

PHP Connect to MySQL

Post by :    Date : 2014-11-30 02:07:20

  • Share on Facebook

Open a Connection to MySQL Before we can access data in the MySQL database, we need to be able to connect to the server: Example (MySQLi Object-Oriented)

?php
$servername = "localhost";

$username = "username";

$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password); // set username & Password

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

?>

Related Posts