MySQLi with PHP

Below is the simple PHP script to connect database using mysqli


$link = mysqli_connect("", "username", "password", "database_name");

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;

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;

$result = $link->query("SELECT * FROM `customer_entity` WHERE `entity_id`=1");
$row = $result->fetch_assoc();


Hope this is helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top