Subscribe Us

header ads

How to connect to mysql with php

Connecting php with mysql using MySQLi method

The following code is for MySQLi

This only work with mysql

<?php
$servername = "localhost";
$username = "username";
$password = "password";

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

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

Post a Comment

0 Comments