我已經爲root設置了密碼並授予root的所有權限。它爲什麼說它被拒絕?PHP中的MySQL連接錯誤
****mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\photo_gallery\includes\database.php on line 56
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\photo_gallery\includes\database.php on line 56
The Query has problemAccess denied for user 'SYSTEM'@'localhost' (using password: NO)
代碼如下:
<?php
include("DB_Info.php");
class MySQLDatabase
{
public $connection;
function _construct()
{
$this->open_connection();
}
public function open_connection()
{
$this->connection = mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);
if(!$this->connection)
{
die("Database Connection Failed" . mysql_error());
}
else
{
$db_select = mysql_select_db($DB_NAME,$this->connection);
if(!$db_select)
{
die("Database Selection Failed" . mysql_error());
}
}
}
function mysql_prep($value)
{
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
// Quote if not a number
if (!is_numeric($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
public function close_connection()
{
if(isset($this->connection))
{
mysql_close($this->connection);
unset($this->connection);
}
}
public function query($sql)
{
$result = mysql_query($sql);
$this->confirm_query($result);
return $found_user;
}
private function confirm_query($result)
{
if(!$result)
{
die("The Query has problem" . mysql_error());
}
}
}
$database = new MySQLDatabase();
?>
請不要回滾修訂以處理代碼格式。 – Yacoby 2010-04-16 11:40:44
http://stackoverflow.com/questions/2650033/i-am-getting-error-like-mysql-connect-acces-denied-for-systemlocalhostusing-p – 2010-04-16 11:44:13
global $ DBSERVER,$ DBUSER,$ DBPASS, $ DBNAME; $ DBSERVER =「localhost」; \t $ DBUSER =「root」; \t $ DBPASS =「」;(有我設定的密碼) \t $ DBNAME =「photo_gallery」; – Vicky 2010-04-16 11:53:46