You are here : phpmysqlimysqli_connect

mysqli_connect() - mysqli

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


Syntax

mysqli_connect(host,username,password,dbname,port,socket);


Example

<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>


Output / Return Value


Limitations


Alternatives / See Also


Reference