2011-11-29 90 views
0

mysql_connect语句之前的一些注释告诉我将值/变量名修改为我的安装。我现在正在使用xamp并在php.ini中查找。真的不知道问题出在哪里。请指教。谢谢。使用mysql_connect()语句获取错误消息

PHP:

$dbhost = 'localhost'; //unlikely to require changing. 
$dbname ='publication'; //moify these 
$dbuser = 'username'; //variables 
$dbpass = 'password'; //// to your installation 
$appname = 'Robot City'; // and preference 

mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); 

错误消息:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\xampp\htdocs\ajaxpagination\testpage.php on line 10 
Access denied for user 'username'@'localhost' (using password: YES) 

回答

0

而不是调查php.ini,你必须看看你的XAMPP文档。
我确定它包含您必须使用的数据库凭证。

由于胡乱猜测尝试使用

$dbname ='test'; //moify these 
$dbuser = 'root'; //variables 
$dbpass = ''; 

但同样 - 参考文档的实际值。

您还有机会在XAMPP安装过程中自己输入它们。

请注意,我从未在我的生活中见过这个应用程序。我只写出大多数应用程序的工作原理。

2

这有什么好做的php.ini。你为mysql提供了错误的用户名/密码,或者你没有在mysql中正确配置该帐户。

show grants for [email protected];当你在mysql中运行时显示什么?

+0

OP:快速提示。你在mysql控制台中运行该命令。 – Flukey

+0

错误1044(42000):Acess denied for used''@'localhost'to databse'mysql'。 – expiredninja

0

错误的用户名和密码。期!!!尝试

$dbhost = 'localhost'; //unlikely to require changing. 
$dbname ='publication'; //moify these 
$dbuser = 'root'; //variables 
$dbpass = ''; //// to your installation 
$appname = 'Robot City'; // and preference