Fatal error: Call to a member function fetch_assoc() on null on line 9

后端 未结 2 1703
生来不讨喜
生来不讨喜 2021-01-29 14:54

I don\'t understand

Не понимаю, в чем заключается ошибка

query(\"SET         


        
2条回答
  •  生来不讨喜
    2021-01-29 15:33

    1. The $result_set is outside the function scope. You can't access it within the function.
    2. You're selecting from a string not a table name

    Try the following changes:

    set_charset("utf-8"); //Better to do it this way
        $result_set = $mysqli->query ("SELECT * FROM `product`"); //Not the ` instead of '
    
        while (($row = $result_set->fetch_assoc()) != false) {
            print_r ($row);
            echo "
    "; } $mysqli -> close(); }

    You can run this function from anywhere.

提交回复
热议问题