Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP mysqli_connect() Function

PHP mysqli_connect() Function

PHP MySQLi Reference Manual PHP MySQLi Reference Manual

Example

Open a new connection to the MySQL server:


Definition and Usage

The mysqli_connect() function opens a new connection to the MySQL server.


Syntax

mysqli_connect(

host,username,password,dbname,port,socket

)

;

Parameters Description
host Optional. Specifies the hostname or IP address.
username Optional. Specifies the MySQL username.
password Optional. Specifies the MySQL password.
dbname Optional. Specifies the default database to use.
port Optional. Specifies the port number to use when attempting to connect to the MySQL server.
socket Optional. Specifies the socket or named pipe to use.

Technical Details

Return Value: Returns an object representing the connection to the MySQL server.
PHP Version: 5+

PHP MySQLi Reference Manual PHP MySQLi Reference Manual