Connecting PHP to Mysql

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.

http://septiadi.com/2011/02/17/connecting-php-to-mysql/

Advertisements

4 responses to “Connecting PHP to Mysql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: