0

I want to select some items from table, but the problem is shown that "Access denied for user 'root'@'localhost' (using password: NO)". The db system cannot select something from table. What can I do?

 <html>
 <body>
 <?php
 include ('opendb.php');
 ......
 echo "Date: " . date("Y/m/d") . "<br>";
$result = mysql_query("SELECT count(semail) AS av FROM `table` ")or die( 
 mysql_error());  
  $row = mysql_fetch_assoc($result) or die("No rows returned by query"); 
echo "Daily Volume: ".$result;
  ...... ?>
10
  • can you include the code of opendb.php here Commented Dec 11, 2013 at 6:48
  • it's a permission problem, I think root@localhost need password Commented Dec 11, 2013 at 6:49
  • Try to log on to phpMyAdmin using the same credentials as specified in opendb.php, does that work? Commented Dec 11, 2013 at 6:50
  • well we kinda need to see opendb.php, but I am guessing its just a simple permission problem! you need to input a password. Commented Dec 11, 2013 at 6:52
  • Its a privilege problem. If you don't have privileges to access the database or the credentials supplied to the database.php doesn't match to mysql. Commented Dec 11, 2013 at 7:00

3 Answers 3

1

the problem is with your opendb.php file
make sure your database connections credentials are correct.
For some db the default password is root(LAMP environment)

Sign up to request clarification or add additional context in comments.

Comments

0

Probably you do not have any password associated to root so instead of 'NO' left the password equal to '' i.e. empty in your opendb.php !

Comments

-1

in opendb.php you might have used mysql_connect() function use like this. This will solve your problem

 $con = mysql_connect("localhost","root","") or die("sorry not connected");

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.