Close

How to Connect MySQL Database with PHP

Here are the basic steps to connect MySQL database with PHP for your website.

<?php
$databaseServer = 'LOCALHOST';
$databaseUser = 'USERNAME';
$databasePassword = 'PASSWORD';
$databaseName= 'DATABASE';

$connection = mysqli_connect($databaseServer, $databaseUser, $databasePassword) or die('Could not connect to the database server');
$database = mysqli_select_db($connection, $databaseName) or die ("Unable to select database.");
?>

Leave a Reply

Your email address will not be published. Required fields are marked *