0

I am trying to run the code ..I am getting this error:

Fatal error: Uncaught Error: Call to a member function fetch_row() on bool in C:\xampp\htdocs\mayuroutlet\php_action\createOrder.php:93 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mayuroutlet\php_action\createOrder.php on line 93

This is the code at line 83 to 101:

for($x = 0; $x < count($_POST['productName']); $x++) {          

    $updateProductQuantitySql = "SELECT product.quantity FROM product WHERE product.product_id = " . $_POST['productName'][$x] . "";

    $updateProductQuantityData = $connect->query($updateProductQuantitySql);

    

    

    while ($updateProductQuantityResult = $updateProductQuantityData->fetch_row()) {

        $updateQuantity[$x] = $updateProductQuantityResult[0] - $_POST['quantity'][$x];                         

            // update product table

            $updateProductTable = "UPDATE product SET quantity = '".$updateQuantity[$x]."' WHERE product_id = ".$_POST['productName'][$x]."";

            $connect->query($updateProductTable);

What am I doing wrong?...Thanks in Advance!

Siddo
  • 1
  • TL/DR: check for errors every time you `$connect->query()`. Variations on this question appear on Stack Overflow frequently. – Bill Karwin Aug 04 '21 at 20:36
  • I ask this every time I see it, but no one ever gives an answer: Why do you end the SQL assignment with `. ""`? Concatenating an empty string doesn't do anything. – Barmar Aug 04 '21 at 20:37

0 Answers0