2
votes

I was making the website for my retro Habbo with 000webhost and I found this eror

Warning: mysql_query() [function.mysql-query]: Access denied for user 'a8004576'@'localhost' (using password: NO) in /home/a8004576/public_html/global.php on line 25

SCRIPT at line 25:

$server_statut_sql = mysql_query("SELECT users_online,rooms_loaded FROM server_status LIMIT 1") or die(mysql_error());
$server = mysql_fetch_assoc($server_statut_sql);
if ($page_ban != 1)
{
    $verif_banip = mysql_query('SELECT value FROM bans WHERE value = "'.$_SERVER['REMOTE_ADDR'].'"');
    if(mysql_num_rows($verif_banip) == 1){
        Redi('banned');
    }
}
if ($page_maintenance != 1) {
    if ($maintenance == 1) {
        Redi('maintenance');
    }

this is my mysql file

    <?php
$username = "a800xxxxxx";
$password = "xxxxxxxxxxxxx";
$hostname = "mysql1.000webhost.com"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) 
 or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("a800xxxxxx",$dbhandle) 
  or die("PK TU FAIT CHIER SALE FDP");

//execute the SQL query and return records
$result = mysql_query("SELECT id, model,year FROM cars");

//fetch tha data from the database 
while ($row = mysql_fetch_array($result)) {
   echo "ID:".$row{'id'}." Name:".$row{'model'}."Year: ". //display the results
   $row{'year'}."<br>";
}
//close the connection
mysql_close($dbhandle);
?>
3
Did you read the error message? The account you're using to log into mysql is not permitted to access that table.Marc B
You most likely forgot to configure your password for mysql_connect.Joachim Isaksson
Where do you call the function mysql_connect? It's also suggested that you don't use MySQL_* functions, they are deprecated. Try MySQLi, or PDO instead.Connor Gurney
Either your user or password is wrong or it does not have access to that particular databaseedwardmp

3 Answers

1
votes

Most likely you forgot to call mysql_connect (or include the script that calls it). Consequently, the first call to mysql_query is trying to log in using (incomplete) automatic information and failing. The hint is that the error message is the one typically returned by mysql_connect when invalid credentials are supplied, but it's coming from mysql_query instead.

0
votes

In your mysql_connect function, wherever that is, you either did not provide a password or it was incorrect. Sometimes you need to determine from your host where your mysql server resides, as it is not always running on localhost.

0
votes

The bottom of your connect file disconnects ?

//close the connection
mysql_close($dbhandle);

It seems your disconnecting and them mysql_query is trying to reconnect