This question has already been answered:

$result = mysqli_query($link, "SELECT first_name FROM example1"); 

How can echo output the result using echo?

Reported as a duplicate by members of Mike , LFC , meine , Alex , freim on Apr 14 at 4:52 pm .

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 .

    1 answer 1

    The mysqli_query () function returns an object of type mysqli_result, or false. With echo you can't get it out. The easiest way to display it for debug:

     $result = mysqli_query($link, "SELECT first_name FROM example1"); if ($result) { $arr = mysqli_fetch_all($result, MYSQLI_ASSOC); echo "<pre>"; print_r($arr); echo "</pre>"; } 

    The mysqli_fetch_all () function extracts all the data from the result and puts it into an array. The array type is specified by the second parameter.