0

I have edited all the privileges for the user 'root'@'localhost for table tblmembers

but still,

SELECT command denied to user ''@'localhost' for table 'tblmembers'

What is the problem? I'm looking for a solution for almost two days, and still I cant find answers.

Here is my code for selection:

<?php 
$con = mysqli_connect('localhost','root','','add');
if(mysqli_connect_errno())
{
    echo 'Cannot connect to database:' . mysqli_connect_errno();
}
$order = "SELECT firstName,lastName,ID FROM add.tblmembers";
$result = mysql_query($order);
if($result === false)
{
    die(mysql_error());
}
echo "<table>";     
while($row = mysql_fetch_array($result)){
    echo "<tr><td>" . $row['firstName'] . "</td><td>" . $row['lastName'] . "</td><td>" . $row['ID'];
}
echo "</table>";
mysql_close($con);
?>
Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
  • as from error ''@'localhost' means that you are trying to connect with empty username ... that is strange because your mysqli_connect('localhost','root','','add'); is ok. you sould do this first " grant all on *.* to 'root'@'localhist' identified by 'your password here' ". – pregmatch Jan 17 '14 at 01:31
  • where should i put those codes? – user3204815 Jan 17 '14 at 02:08
  • Now I got it! haha I just make mysqli_connect to mysql_connect. Thanks for the help! :) – user3204815 Jan 17 '14 at 03:30
  • Glad you're getting somewhere -- but the mysql library has been depreciated; it's advised to use PDO or mysqli instead. Learn more at https://stackoverflow.com/questions/13944956/the-mysql-extension-is-deprecated-and-will-be-removed-in-the-future-use-mysqli – Isaac Bennetch Jan 17 '14 at 05:06

0 Answers0