In this tutorial we are connect PHP with MySQL database in Procedural Form.
To connect with database we have three option :
1: Procedural.
2: Object Oriented.
3: PDO
In this tutorial we are learning procedural way.
Just copy the below code and create config.php file in your xampp or wamp and paste the code.
To connect with database we have three option :
1: Procedural.
2: Object Oriented.
3: PDO
In this tutorial we are learning procedural way.
Just copy the below code and create config.php file in your xampp or wamp and paste the code.
<?php
$servername = "localhost";
$username = "Your username";
$password = "Your password";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
If all go good then you see "Connected successfully" message on your screen otherwise "Connection failed" error.
Happy Coding.
0 Comments