MySQL Forums
Forum List  »  PHP

Re: MySql database connection
Posted by: Alphanso Tech
Date: November 18, 2015 01:25AM

<?php
$host = "127.0.0.1";
$user = "my_user";
$password = "my_password";
$database = "my_db";
$link = mysqli_connect($host, $user,$password , $database);

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 $database database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);
?>

Options: ReplyQuote


Subject
Written By
Posted
August 27, 2015 02:34PM
Re: MySql database connection
November 18, 2015 01:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.