Connect to Mysqli database using PHP5

Connect to Mysqli database using PHP5, this is simple article for connecting to Mysqli database using PHP5. Here i’ll use two methods for connecting with mysqli database. One is procedural and the other one is object oriented. For the first one i’m using is mysqli_connect. And the next one is Object Oriented. Just pass the database login credentials mysqli_connect function.

Connect to Mysqli database using PHP5 in procedural method

Here in mysqli_connect, i’m passing all the values

  • Host Name
  • User Name
  • Password
  • Database Name
$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));

Connect to Mysqli database using PHP5 in Object Oriented

Provide database host, database user name, database password and finally database name.

$mysqli = new mysqli("myhost", "myuser", "mypassw", "mybd");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

This is simple article for Connecting to Mysqli database using PHP5

Vivek Vengala

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

Get 6 Months Premium Hosting Free  *only limited time

Join My Facebook Group to Receive Coding Tutorial for Free