PHP provides mysql_connect() function to open a database connection. This function takes five parameters and returns a MySQL link identifier on success or FALSE on failure. Its syntax is as follows −
Syntax
connection mysql_connect(server,user,passwd,new_link,client_flag);
Following table give us the parameters used in the syntax above −
Sr.No | Parameter & Description |
1 | Server Optional − The host name running the database server. If not specified, then the default value will be localhost:3306 |
2 | User Optional − The username accessing the database. If not specified, then the default will be the name of the user that owns the server process |
3 | Passwd Optional − The password of the user accessing the database. If not specified, then the default will be an empty password |
4 | new_link Optional − If a second call is made to mysql_connect() with the same arguments, no new connection will be established; instead, the identifier of the already opened connection will be returned |
5 | client_flags Optional − A combination of the following constants −
|