$sql = mysql_query("SELECT SUM(sumer) as total FROM out"); $result = mysql_query($sql); $values = mysql_fetch_assoc($result);//ошибка echo $values['total']; 

It still outputs a boolean (displays an error):

"Warning: mysql_fetch_assoc () expects parameter 1 to be resource, boolean given in ..."

Reported as a duplicate by participants Alexey Shimansky , Melky , Mike , aleksandr barakin , rdorn 25 Dec '16 at 2:18 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    2 answers 2

    What do you want to say?

    $sql = mysql_query("SELECT SUM(sumer) as total FROM out"); $result = mysql_query($sql);

    Well, sometimes it's helpful to read the documentation.

    For SELECT, SHOW, DESCRIBE, EXPLAIN, and other queries that return a result from multiple rows, mysql_query () returns a handle to the result of the query (resource), or FALSE if an error occurs.

    For other types of SQL queries, INSERT, UPDATE, DELETE, DROP and others, mysql_query () returns TRUE on success and FALSE on error .

    Error text can be obtained by calling the mysql_error() function

       $sql = "SELECT SUM(sumer) as total FROM out"; $result = mysql_query($sql); $values = mysql_fetch_assoc($result);//ошибка echo $values['total']; 

      This is the way to work. You have an extra mysql_query