mysqli database connection php
snippet in php

mysqli connect

user757


<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");

// Check connection
if ($mysqli -> connect_errno) {

  echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  
  exit();

  }
?>
 

mysqli database connection php

user5636


<?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();

    
  exit();
}

?>
 

mysqli_connect parameters

user8696

mysqli_connect ( "host", "username", "password", "database_name" )