Wednesday, December 9, 2009

9:06 AM
Mysql is mostly used with PHP for storage and retrieving purpose .Before you can access a data in a database, you need to create a connection with the database.
In PHP the MYSQL connection obtained by the following code


Servername : Specifies the server to connect to. Default value is "localhost:3306"
Username : Specifies the username to log in with. Default value is "root"
Password : Specifeis the password to log in with. Initially there is an empty password.Default value is  " "


$con = mysql_connect("localhost","root","pwd");
if (!$con)
  die('Could not connect: ' . mysql_error());

// some code

Here .,

 Localhost - servername
 root - Username
 pwd - Password ( already specified password for database)


The above will be used to disconnect the connection with MYSQL.