English 中文(简体)
用户 Acctname 获取错误访问被拒绝@ localhost (使用密码: NO)
原标题:Getting Error Access denied for user acctname @ localhost (using password: NO)
  • 时间:2012-05-22 20:23:18
  •  标签:
  • php

我几周前就安装了MAMP, 并且一直用它来开发PHP, 没有问题。 我最近开发了一个脚本, 该脚本将计算每天链接点击多少次, 并且效果极好。 现在我需要将信息显示在网络浏览器中 。

在确保我与数据库连接之后,我写了以下文章:

    $query = "SELECT * FROM banners";
    $result = mysql_query($query);
    if (!$result) die ("Database access failed: " . mysql_error());

当我去页面查看是否有错误时,我可以看到

数据库访问失败: 用户 Acctname 无法访问@ localhost (使用密码: NO)

发生什么了,我怎么解决?

谢谢

算了,我知道了,谢谢大家!

问题回答

您需要确保用户对“ banners” 表格拥有 SELECT 权限。 您可以在 phpMYSQLAdmin 网站上点击 PhpMYSQLAdmin 权限 。

在您的例子中,我没有看到您正在连接 DB 并选择一个数据库来运行查询。 您是否在查询前做了类似的事情?

mysql_connect($host, $username, $password);
mysql_select_db($database_name);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签