How to connect MySQL Database using PHP
We have seen how to fetch youtube videos using simple javascript in our previous tutorial. Today's tutorial is about connecting our database using PHP. Since PHP is a dynamic scripting language and it uses mysql database in the back end to store the data. That means the php file has to be configured to connect the database. This can be done very easily with a simple php code. This tutorial will help you to connect to the database. The database connection needs four parameters to be passed into two functions. mysql_connect () and mysql_select_db () are the two functions to connect to the database. mysql_connect () function requires three parameters and this function is used to connect to the database. and mysql_select_db () function is used to select the database. Here is the simple code that you can simply copy and use to connect your database with php. <?php $dbhost ...
