Blog > detail

Just my tiny mind

Connecting PHP to Mysql

26-2-2012 Admin General 2 Comments

Connecting PHP to Mysql

Connecting PHP to Mysql is very simple and easy to do.


What you need is to type code below into your PHP file:


$host = 'localhost';//host name, in this case we use localhost

$user = 'root';//user name, in this case we use root

$pass = 'password';//password, in this case we use password


$conn = mysql_connect($host, $user, $pass)

or die('Connection Failed');//will show "Connection Failed" if the connection failed


$db_name = 'member';//declare the database that will be used

mysql_select_db($db_name);//selecting the data base


Finish. We just done Connecting PHP to Mysql.

Connecting PHP to Mysql Connecting PHP to Mysql Connecting PHP to Mysql

Connecting PHP to Mysql Connecting PHP to Mysql Connecting PHP to Mysql

Connecting <a href=PHP to Mysql" width="1" height="1" />

word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word

Connecting PHP to Mysql

Connecting PHP to Mysql

Connecting PHP to Mysql