Fatal error: mysqli_sql_exception not detected: No index used in query / prepared statement SELECT * FROM Product

advertisements

This question already has an answer here:

  • Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'No index used in query/prepared statement' 4 answers

I have looked at our posts regarding this problem, however, the posts just suggest to use mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT) instead of error_reporting(E_ALL). I have made these changes which indeed removed the error message, but now nothing appears on my webpage, it is just a blank white page, even though it has a few forms on it. So i started using error_reporting(E_ALL) once again

I was wondering if there is another reason for this error. It is a simple select statement that is causing this problem, The php file consists of 4 forms and has a insert on duplicate key statement just before it.

   $prod_sel = $dbc->query("SELECT * FROM Product");
        $prod_sel->data_seek(0);
        while ($output = $prod_sel->fetch_assoc()) {
            $prod_run .= $output['Product_Name'] . '<br>';
            $_SESSION['Product_Name'] = $output['Product_Name'];
        }
       //session_start does not work here
        print "Restaurant is :" . $_SESSION['Product_Name'];
        $prod_sel->free();
        $prod_sel->close();


Your Product table has no column indexed, you should fix it for better performance
You can always disable this mysqli error just by adding this code

mysqli_report(MYSQLI_REPORT_INDEX);

You can find here the complet list about Enabling/Disabling the internal report functions
I suggest you to read this good article about PHP & MYSQL Communication