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
mysql_connect(Servername,username,password);
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 " "
Example:
$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)
mysql_close($con);
The above will be used to disconnect the connection with MYSQL.
mysql_close($con);
The above will be used to disconnect the connection with MYSQL.
0 comments:
Post a Comment