The mysql_connect function is used to connect to a MySQL Server.
Syntax:
resource mysql_connect (string $Hostname, string $Username, string $Password);
Arguments:
$Hostname
The hostname is the URL or the IP address of the MySQL server. If the PHP script is running on the same system as the MySQL server, “localhost” can be used as a hostname.
$Username
The username must be a valid user of the MySQL server.
$Password
The password must be the MySQL password for the username.
Return value:
If the connection is successful, the return value will be the handle of the connection.
If the connection fails, the return value wil be a boolean false.
Example code:
<?php $UserName = 'abc'; $Password = '8sj27s'; $DbHandle = mysql_connect ('localhost', $UserName, $Password); if (!$DbHandle) { die 'No database connection could be established.'; } ?>
Tags: authentication, mysql_connect