2

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);
?>
4
  • 2
    Did you read the error message? The account you're using to log into mysql is not permitted to access that table. Commented Jul 10, 2013 at 19:22
  • You most likely forgot to configure your password for mysql_connect. Commented Jul 10, 2013 at 19:23
  • 1
    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. Commented Jul 10, 2013 at 19:23
  • Either your user or password is wrong or it does not have access to that particular database Commented Jul 11, 2013 at 21:47

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.