My sql connection in php

Untitled Document

Making connection with mysql database in php is a very easy job.In php mysql_connect() function opens connection , It takes at least three arguments host (here localhost ), username and password.First argument is host name, it may be an IP address or domain name like infosearchshop.com. Second argument is username for mysql and third one is password for mysql connection. Here it is assumed that mysql is on same host where this script is running, therefore we are using localhost.

 
<?php
$host="localhost";
$username="user_name";
$password="password";
$link=mysql_connect($host,$username,$password);

if($link)
{ //connection is opened
echo "Connection established<br/>";
mysql_close($link);

}
else
{ //otherwise give error
echo mysql_error();
}
?>