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

PHP mysqli_real_connect() Function

PHP mysqli_real_connect() Function

PHP MySQLi Reference Manual PHP MySQLi Reference Manual

Example

Open a new connection to the MySQL server:


Definition and Usage

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

The mysqli_real_connect() function differs from mysqli_connect() in the following ways:


Syntax

mysqli_real_connect(

connection,host,username,password,dbname,port,socket,flag

)

;

Parameters Description
connection Required. Specifies the MySQL connection to use.
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.
flag Optional. Specifies different connection options. Possible values:
 
  • MYSQLI_CLIENT_COMPRESS - Use the compressed protocol
  • MYSQLI_CLIENT_FOUND_ROWS - Return the number of matched rows (not the number of affected rows)
  • MYSQLI_CLIENT_IGNORE_SPACE - Allow spaces after function names, making function names reserved words
  • MYSQLI_CLIENT_INTERACTIVE - Allow inactive interactive_timeout seconds before closing the connection
  • MYSQLI_CLIENT_SSL - Use SSL encryption
  • |

    Technical Details

    Return Value: Returns TRUE on success, FALSE on failure.
    PHP Version: 5+

    PHP MySQLi Reference Manual PHP MySQLi Reference Manual