Hello, everybody, I hope you all of fine, Now in this tutorial we Will learn to connect How to Connect PHP to MySQL. PHP is one of the most popular OOP programming languages, which is used to make a Web Applications and also Desktop Applications. There are many different OOP programming languages helpful for a different purpose.
But, PHP is a flexible and easy programming language. Yes, PHP is easy versus another programming languages such as Java, C#, Python etc. So, you can learn this language quickly, I hope after learning PHP language you are able to Make a Web Application as well.
You May Also Like: Connect C# with SQL Server
You May Also Like: Java Connectivity with MySQL
However, in this tutorial, you will learn How to Connect PHP to MySQL. After the make connection, you are able to Insert, Update, Delete, View and also search. First of All, you need to make a connection between PHP to MySQL.
Database Connection in PHP with MySQL in XAMPP
I will tell you two different ways connect PHP to MySQL. First of all, you need to connect PHP to MySQL. Then you will able to connect PHP with Own Database. The Connection codes are below mentioned, you just copy it and paste into your own code editor.
//Connect PHP to MySQL
@mysql_connect('localhost','root','') or die(' Please Check the Connection ');
echo ' Connection Successfully ';
After the make connection, you will able to connect php with your database. I have mentioned below codes, you need to copy it and paste your own code editor. But, remember I have made DEMO database so I have included ‘demo’ you need to enter your own database name here.
//Connect PHP to Database
mysql_select_db('demo') or die (' Please Check the Database Name ');
echo ' Database Connection Successfully';
This is one way to connect PHP to MySQL, but you can use conditions like if else. Below I have shared the codes, you can also use this method.
How to Connect PHP to MySQL
exit (' Please Check the Connection ');
echo ' Connection Successfully';
exit (' Please Check the the Database ');
I hope you have understood as well, and you will learn it something new. Kindly, share my content on social networks, and subscribe my website social networks pages like Facebook, Google+, Twitter, YouTube and Email for post updates.
If you have any question/suggestion about this topic, comment or email me after receiving your email or comment, I will reply with your answer maximum 24 hours. Thanks Again for a visit, Read my Complete Article. Keep touch my website, I will share very soon applications tutorial.