$db_host,$db_username,$db_password,$db_database is variable and the below mysqli_connect is a function. $connection is also a variable. i am describing about this connection. You will change a variable name easily its not a necessary you are using a $connection or $conn or something like that. Now came on function ..because our hidden part is mysqli_connect function.Because Mostly Developer using this function. Developers know a one thing only if we using mysqli_connect then Database Connection will be established. Dnt know About the Backend of function.

that type of code are using in mysqli_connect Function

resource mysql_connect ([ string $server = ini_get(“mysql.default_host”) [, string $username = ini_get(“mysql.default_user”) [, string $password = ini_get(“mysql.default_password”) [, bool $new_link = FALSE [, int $client_flags = 0 ]]]]] )

For Php 5.5 version We are using mysql_connect.

For Php 7 version We are using mysqli_connect or PDO.

<?php

$db_host=”localhost”;
$db_username=”root”;
$db_password=””;
$db_database=”DATABASE NAME”;

$connection=mysqli_connect($db_host,$db_username,$db_password,$db_database);

if(!$connection)

{

echo “Sql Error”;

}
else

{
echo”connected sucessfully”;

}

?>


Leave a Reply