Issues Questions Call to a member function fetch_assoc() on boolean

4612 asked on

Call to a member function fetch_assoc() on boolean in C:\xampp\htdocs\websites\ajax-shopping-cart-files-master\index.php on line 92

this is the issue iam getting

    Add Answer
    All HTML codes will be stripped in the comment, except inline <code> HTML tag.
    1 Answer
    1 answered on

    That is because MySqli query returns false on failure. In your case maybe you have not created the required table in your database. You need to import products_list.sql in your database and make necessary changes in config.inc.php.

    But if you have already created table, just add this code to display any MySqli Error on the page. $mysqli->error will output MySqli error.

    //mysqli query
    $results = $mysqli_conn-&gt;query("SELECT product_name, product_desc, product_code, product_image, product_price FROM products_list");
    if (!$result) { //on failure display error
        print "There was an mysql error :" . $mysqli_conn-&gt;error;
        exit;
    }

    I have also made changes in Github file, you can compare the changes.

      All HTML codes will be stripped in the comment, except inline <code> HTML tag.

      Can You Answer this? Help us answer the question!

        • Answer
        Supports basic Markdown syntax. Excluded syntaxes (Headers, Lists, Blockquotes, Table, Images)