mysqli_connect

(PHP 5, PHP 7)

mysqli_connectAlias of mysqli::__construct()

Description

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

Although the mysqli::__construct() documentation also includes procedural examples that use the mysqli_connect() function, here is a short example:

Examples

Example #1 mysqli_connect() example

<?php
$link 
mysqli_connect("127.0.0.1""my_user""my_password""my_db");

if (!
$link) {
    echo 
"Error: Unable to connect to MySQL." PHP_EOL;
    echo 
"Debugging errno: " mysqli_connect_errno() . PHP_EOL;
    echo 
"Debugging error: " mysqli_connect_error() . PHP_EOL;
    exit;
}

echo 
"Success: A proper connection to MySQL was made! The my_db database is great." PHP_EOL;
echo 
"Host information: " mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);
?>

The above examples will output:

Success: A proper connection to MySQL was made! The my_db database is great.
Host information: localhost via TCP/IP
add a note add a note

User Contributed Notes 1 note

up
0
ratblack7 at gmail dot com
2 hours ago
/*
by JPF

ratblack7@gmail.com

*/

<?php

$var
= "rand";

echo
$var(0,10);//true print rand

?>

<?php

function connect($connect,$sentencia){

$connect=array(

mysqli_connect,
mysqli_select_db,
mysqli_query,
mysqli_fetch_assoc

);

$sentencia=array(

"'localhost','root',''",
"my_database",
"select * from table_connect",

);
   
   
$sentencia[]=$connect[3];
   
   
    for(
$i=0;count($conect);$i++){
   return
$i;
    if(
$connect[$i]($sentencia[$i]) === TRUE){
   return
$connect[$i]($sentencia[$i]);
    return   
"<br>Conection true";
    }else{return
"No connect Failed";}
 
}
//for

   
}//fun

echo  connect($connect,$sentencia);

   

?>
To Top