0

I have been trying to connect my PHP file to MySQL database for a while, now I'm using WAMP server and encountering error 1045, I have also setup a password and tried various settings given on net.

this is the scenario

<?php
$link = mysqli_connect("127.0.0.1", "root", "password", "registration");

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);
?>

here is the code I'm running, registration is the database,I have created it using phpmyadmin

RMcLeod
  • 2,561
  • 1
  • 22
  • 38
asbn
  • 1

1 Answers1

0
<?php
$link = mysqli_connect("127.0.0.1", "root", "", "registration");

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);
?>
Wprog_dy
  • 67
  • 5