SELECT命令被拒绝用户'''localhost'表'任务'

I keep getting that error even though all the privileges have been provided to the localhost. I can insert data from same username/pass but it doesn't retrieve it.

I have already tried the methods of commenting the lines in config.inc.php and executing GRANT.

Here's my code below

<?php
        $servername = "localhost";
        $username = "root";
        $password = "";
        $dbname = "to_do_list";

        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn->connect_error) {
            die("Connection failed: " . $conn->connect_error);
        } 

        $query = "SELECT `task`, `date_of_task`, `time_of_task`,`id`  FROM `to_do_list`.`tasks`;"; 

       $result = mysql_query($query) or die($query."<br/><br/>".mysql_error());


      while($row = mysql_fetch_array($result)){         
        echo "<tr>".
        "<td>" . $row['task'] . "</td>".
        "<td>" . $row['date_of_task'] . "</td>".
        "<td>" . $row['time_of_task'] . "</td>".
        "<td> <button value=\"Edit\" class=\"btn btn-warning\"> </td>".
        "<td> <button value=\"Edit\" class=\"btn btn-warning\"> </td>".
        "</tr>";  
        }
        mysql_close();
    ?>

Thanks.

Changing to the following code solved my problem. I think it was maybe due to the conflict of using query as a variable.

$sql = "SELECT task,date_of_task,time_of_task,id  FROM to_do_list.tasks;";
$result = $conn->query($sql) or die($sql."<br/><br/>".mysql_error());


if ($result-> num_rows > 0) {
    // output data of each row
    while ($row = $result->fetch_assoc())

I do see an extra semicolon at the end of your query:

$query = "SELECT ... FROM `to_do_list`.`tasks`;"; 

As well the MySQL you are using is deprecated.

You are opening a connection with MySQLi:

$conn = new mysqli($servername, $username, $password, $dbname);

Then you are using mysql_* functions:

$result = mysql_query($query) or die($query."<br/><br/>".mysql_error());

while($row = mysql_fetch_array($result)){   

Change your code to use only MySQLi functions, and the error will disappear.