April 7, 2015

Connect to the MYSQL DATABASE using MYSQLI connection

Now a days every website uses database to store particular data of their users. In this tutorial we will discuss about mysqli connection.

<?php

$db = new mysqli('localhost','user','password','databasename');

if($db->connect_errno > 0){
die("Connection Error occured");
}

?>

You can also handle the error using try catch blocks. that's it you just need to include this file in every other files where ever you are processing data operating on data from the database. 
Note: Here you need to change user = username, password = your password, databasename = your defined database name. 

If you have any queries please comment below

No comments: