How To Connect Mysql Database Easiest Way in PHP?

In this post i describe how to connect mysql with php easiest way…

What is MYSQL database?
  • MySQL is a database system used on the web
  • MySQL is a database system that runs on a server
  • MySQL is ideal for both small and large applications
  • MySQL is very fast, reliable, and easy to use
  • MySQL uses standard SQL
  • MySQL compiles on a number of platforms
  • MySQL is free to download and use
  • MySQL is developed, distributed, and supported by Oracle Corporation
  • MySQL is named after co-founder Monty Widenius’s daughter: My
Follow 2 steps for connecting MySql database to PHP :

STEP – 1 

  • Are you run your project on local server then your server name is localhost & username is root or if you are run project on live server then enter details as per you set on your live server.After that check entered details right or not.

STEP – 2

<?php
$server = "localhost";
$user = "your username";
$pass = "your password";

// Create connection
$connection = mysqli_connect($server, $user, $pass);

// Check connection
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>

Know More :

mysqli_connect_error() Function :
  • mysqli_connect_error() function doesn’t accept any parameters.
  • PHP mysqli_connect_error() function returns an string value representing the description of the error from the last connection call, incase of a failure. If the connection was successful this function returns Null.

Reference Site : Click Here

Recent Posts

Leave a Reply

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