How to use mysql connect in PHP
In this article I am going to explain about mysql_connect function in PHP.
PHP mysql_connect() Function
The PHP mysql_connect function opens non-persistent MySQL connection.
Syntax of mysql_connect function
mysql_connect(server, userName, password,newlink, clientflag) |
Parameters in mysql_connect function
It have five parameter:
Parameter |
Description |
server |
It specifies the server to connect. |
userName |
It specifies username. |
password |
It specifies password. |
newlink |
In it, if a second call is made to mysql_connect function with the same arguments, no new connection will be established; instead, the identifier of the already opened connection will be returned. |
clientflag |
It can be combination of the many of constants. |
Example of mysql_connect function
<html>
<body>
<?php
$con=mysql_connect("localhost","userName","password");
if(!$con)
{
die("Could not connect:". mysql_error());
}
mysql_close($con);
?>
</body>
</html>
|
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here