Open a new connection to the MySQL server:
<?php$con = mysqli_connect ( "localhost" , "wrong_user" , "my_password" , "my_db" ); // Check connection if (! $con ){ die( "Connection error: " . mysqli_connect_error ());} ?>The mysqli_connect() function opens a new connection to the MySQL server.
mysqli_connect( host, username, password, dbname, port, socket ) ;
parameter | describe |
---|---|
host | Optional. Specify the hostname or IP address. |
username | Optional. Specifies the MySQL username. |
password | Optional. Specifies the MySQL password. |
dbname | Optional. Specifies the database to use by default. |
port | Optional. Specifies the port number to attempt to connect to the MySQL server. |
socket | Optional. Specifies the socket or named pipe to use. |
Return value: | Returns an object representing a connection to the MySQL server. |
---|---|
PHP version: | 5+ |