Blaze Blaze - 5 months ago 38
SQL Question

Warning: mysqli_connect(): (28000/1045): Access denied for user 'mobileto'@'localhost' (using password: NO)

I am trying to access a php database I created online using this url

http://dns.com/data_api/connect.php


I have created the database and it has no username and password atteched to it at the point of creation. When I try to check if the connect.php could establish a connection to the database I get this error

Warning: mysqli_connect(): (28000/1045): Access denied for user 'mobileto'@'localhost' (using password: NO) in /home/mobileto/public_html/data_api/connect.php on line 11
Failed to connect to MySQL: Access denied for user 'mobileto'@'localhost' (using password: NO)


This is the connect.php file

<?php


$username = "";
$password = "";
$hostname = "localhost";
$dbase ="mobileto_holo";

//connection to the database
//$dbhandle = mysql_connect($hostname, $username, $password)
$con=mysqli_connect($hostname,$username,$password,$dbase);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";

//$conn = mysql_connect("localhost","root","");
?>


Please what could be wrong?

Answer

No Username or Password? :o That's impossible. Try giving root as the default username, instead of passing an empty string.

$username = "root";
$password = "";
$hostname = "localhost"; 
$dbase    = "mobileto_holo";