How to connect mySQL using PHP?

Hy, I’m Kashif Nadeem and now i am going to explain you “How to connect mySQL database using PHP?

Try to under this simple connection string given below:

$con = mysqli_connect("localhost", "root", "", "sublimegate");
	echo "Database Connection Problem";
	echo "Database Connection Successful";

In above code you can see that PHP starting and ending tags are given and all mySQL connection Code is written inside these tags.

  • $con : is simple varibale in PHP that holds connections string.
  • mysqli_connect : is aspecial function used to make connection for mySQL. There are three or four parameters can be written inside it.
  • localhost : is your server name if you are using local server.
  • root : is a username that is created on local server to control and access mySQL database.
  • ” “: is a user password. Here blank show that by default root user has no password.
  • sublimegate : is your database name.

3 thoughts on “How to connect mySQL using PHP?

  • August 1, 2019 at 12:16 pm

    Hello there, just became alert to your blog through Google, and found that it is truly informative. I am gonna watch out for brussels. I’ll be grateful if you continue this in future. Lots of people will be benefited from your writing. Cheers!

  • August 10, 2019 at 11:12 pm

    Hi, Neat post. There is an issue with your website in web explorer, would test this¡K IE still is the market chief and a huge element of folks will pass over your great writing due to this problem.


Leave a Reply

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