Thursday, April 1, 2021

How to connect to database in PHP and MySQL

 In this tutorial I will show you how to connect in database in PHP and MySQL.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com





Program Listing


index.php


<?php

$servername = "localhost";

$database = "crude";

$username = "root";

$password = "";


// Create connection


$conn = mysqli_connect($servername, $username, $password, $database);


// Check connection


if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}


echo "Connected successfully to the database.";


mysqli_close($conn);


?>


No comments:

Post a Comment