问题描述
<div class="items"><ul><li><?php echo $msg[$lang]["gtd"];?><div class="text"><强><?php$result = mysql_query("SELECT id FROM games WHERE `starttime` > ".(time()-86400));回声 mysql_num_rows($result);?></strong>
此代码的第 8 行返回错误:
mysql_query() 用户 ''@'localhost' 访问被拒绝(使用密码 no)".
https://stackoverflow.com/search?q=mysql_query%28%29+access+denied+for+user+%40%27localhost%27
这在 SO 和 谷歌.
您似乎根本没有连接到数据库.包括以下内容(当然,使用您的凭据填充函数参数):
$connection = mysql_connect('localhost', 'db_username', 'db_password')或者 die('连接问题:' .mysql_error());mysql_select_db('your_database', $connection);
</div>
<div class="items">
<ul>
<li>
<?php echo $msg[$lang]["gtd"]; ?>
<div class="text">
<strong>
<?php
$result = mysql_query("SELECT id FROM games WHERE `starttime` > ".(time()-86400));
echo mysql_num_rows($result);
?></strong>
</div>
</li>
Line 8 of this code returns the error:
mysql_query() access denied for user ''@'localhost' (using password no)".
https://stackoverflow.com/search?q=mysql_query%28%29+access+denied+for+user+%40%27localhost%27
This is an extremely popular issue on both SO, as well as Google.
You don't appear to have connected to the database at all. Include the following (populating the function arguments with your credentials, of course):
$connection = mysql_connect('localhost', 'db_username', 'db_password')
or die('connection problem:' . mysql_error());
mysql_select_db('your_database', $connection);
这篇关于为什么我的代码返回此错误:mysql_query() access denied for user ''@'localhost' (using password no)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!