mysqli_connect

(PHP 5, PHP 7)

mysqli_connectAlias of mysqli::__construct()

Description

This function is an alias of: mysqli::__construct()

Note:

If mysqli exception mode is not enabled and a connection fails, then mysqli_connect() returns false instead of an object. The mysqli_connect_error() function can be used to fetch the connection error.

add a note add a note

User Contributed Notes 1 note

up
3
mparsa1372 at gmail dot com
28 days ago
Example (MySQLi Object-Oriented)

<?php
$servername
= "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
  die(
"Connection failed: " . $conn->connect_error);
}
echo
"Connected successfully";
?>
To Top