I've installed a WAMP server. Now I want to connect to a MySQL database using php. I have one problem you need to get the username. This is the code I use. Its from php.net http://php.net/manual/en/mysqli.quickstart.connections.php
<?php
$db_host = "localhost";
$db_username = "root";
$db_password = "password";
$db_name = "test";
$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";
?>
I get the following error:
Warning:
mysqli::mysqli()
: in C:\wamp\www\Atletieker\dbconnect.php on line 7 Failed to connect to MySQL: (1045) Accès refusé pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI)Warning:
main()
: Couldn't fetch mysqli in C:\wamp\www\Atletieker\dbconnect.php on line 11
How do I get the username of my database?
$db_password = "";
– viral