Php Folks,
Is this ok or do you have a better way of writing them ?
[code]
if(mysqli_connect_error())
{
echo “Connection Error!” . mysqli_connect_error();
echo “Connection Error Number!” . mysqli_connect_errno();
}
Not sure if I asked you these or opened a thread about them but which do you use and can you rank these 3 so I know your rankings:
[code]
<?php
$link = mysqli_connect(“localhost”, “root”, “test”);
// Check connection
if($link === false){
die(“ERROR: Could not connect. ” . mysqli_connect_error());
}
// Print host information
echo “Connect Successfully. Host info: ” . mysqli_get_host_info($link);
mysqli_close($link);
?>
[code]
<?php
mysqli_connect(“localhost”, “root”, “”, “GFG”);
if(mysqli_connect_error())
echo “Connection Error.”;
else
echo “Database Connection Successfully.”;
?>
[code]
<?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);
?>
Or, if you have a better code then show me.