How many parameters are required for mysqli_connect function in PHP?

How many parameters are required for mysqli_connect?

 five parameters

PHP provides mysqli_connect() function to open a database connection. five parameters are required to connect to mysqli_connect, and returns a MySQLi link identifier on success or FALSE on failure.

Syntax to connect to mysqli_connect()

mysqli_connect(server,user,passwd,new_link,client_flag);

Required parameters for mysqli_connect()


Sr.No.Parameter & Description
1

server

Optional - The host name running database server. If not specified, then default value is localhost:3306.

2

user

Optional - The username accessing the database. If not specified, then default is the name of the user that owns the server process.

3

passwd

Optional - The password of the user accessing the database. If not specified, then default is an empty password.

4

new_link

Optional - If a second call is made to mysqli_connect() with the same arguments, no new connection will be established; instead, the identifier of the already opened connection will be returned.

5

client_flags

Optional - A combination of the following constants −

  • MYSQLI_CLIENT_SSL - Use SSL encryption
  • MYSQLI_CLIENT_COMPRESS - Use compression protocol
  • MYSQLI_CLIENT_IGNORE_SPACE - Allow space after function names
  • MYSQLI_CLIENT_INTERACTIVE - Allow interactive timeout seconds of inactivity before closing the connection

Post a Comment

Previous Post Next Post