我正在爲我的復古哈寶使用000webhost網站,我發現這個錯誤警告:mysql_query()[function.mysql-query]:訪問拒絕用戶'a8004576'@'localhost'(使用密碼:否)
警告:請求mysql_query()[function.mysql-查詢]:訪問被拒絕的用戶 'a8004576' @ '本地主機'(使用密碼:否)在/home/a8004576/public_html/global.php在線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'); }
25行SCRIPT
這是我的MySQL文件
<?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);
?>
你看了錯誤信息?您用於登錄到MySQL的帳戶不允許訪問該表。 –
您很可能忘記爲mysql_connect配置您的密碼。 –
你在哪裏調用函數mysql_connect?還建議您不要使用MySQL_ *函數,它們已被棄用。嘗試使用MySQLi或PDO。 –