Create a connection of MySQL through PHP
IN this article I am going to explain connection in MySQL.
Create a Connection to a MySQL Database
You must have to create connect with MySQL Database before the access data from the database. And for create connection in PHP mysql_connect() function used.
Syntax of MySQL database connection
Parameters in Mysql connect method
There are following three parameters in mysql_connect method:
||Optional. Specifies the server to connect to. Default value is "localhost:3306"
||Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process
||Optional. Specifies the password to log in with. Default is ""
Example of creating MySQL connection
$con = mysql_connect("localhost","gupta","[email protected]");
die('Could not connect: ' . mysql_error());
// other code
mysql_close($con); //closing a connection
You may also want to read these related articles click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here