How to Create mysql Database Connection in PHP - CSNSOl | Latest Government jobs in Pakistan | News Paper jobs | PPSC NTS FPSC Jobs

Post Top Ad

Thursday, 7 January 2016

How to Create mysql Database Connection in PHP

Connect MySQL database first create a connection with MySQL database .
Follow the steps for creating connection to MySQL database in PHP.

 1- creat a database in phpmyadmin .

2-  Define Username Password Server name and   take in variables.


3- use  mysql_connect() take three parameters server name ,username , password, connect to database.

4- use msql_select_db() function take two parameters one is database name , second is mysql_connect() infon in form of variable. Let see in coding example.

5- check the connection conformation.

Complete code for connect mysql database in php.

//connect to database this function
$conn=mysql_connect($servername,$username,$password) ;
// select the database 
// this condition check connection conformations.
echo "Connection is  Create a Successfully ";
echo "Connection is not create";

No comments:

Post a Comment