-1

I'm trying to add products on basket but i'ts not working fine. I'm getting a warning

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\Esigelec Online Sales 2019\cart.php on line 121

I've a database called cart.

<?php
    $ip = getIp();
    $total = 0;
    $sel_price = "select * from cart where ip_add = '$ip'";
    $run_price = mysqli_query($con,$sel_price);
    while($cart_row = mysqli_fetch_array($run_price)){
        $pro_id = $cart_row['p_id'];
        $pro_qty = $cart_row['qty'];
        $pro_price = "select * from products where pro_id = '$pro_id' and sflag = 0;";
        $run_pro_price = mysqli_query($con, $pro_price);
        while ($pro_row = mysqli_fetch_array($run_pro_price)){
            $pro_title = $pro_row['pro_title'];
            $pro_image = $pro_row['pro_image'];
            $pro_price = $pro_row['pro_price'];
            $pro_price_all_items = $pro_price * $pro_qty;
            $total += $pro_price_all_items;
            ?>
            <tr align="center">
                <td><input type="checkbox" name="remove[]"
                           value="<?php echo $pro_id; ?>"></td>
                <td><?php echo $pro_title; ?> <br>
                    <img src="admin/product_images/<?php echo $pro_image; ?>"
                         width="60" height="60">
                </td>
                <td><input size="2" name="qty[]" value="<?php echo $pro_qty;?>">
                    <input name="product_id[]" type="hidden" value="<?php echo $pro_id;?>">
                </td>
                <td><?php echo "$".$pro_price ; ?></td>
                <td><?php echo "$".$pro_price_all_items; ?></td>
            </tr>
            <?php
        }
    }
?>

This line causes the problem: while ($pro_row = mysqli_fetch_array($run_pro_price))

CVK
  • 51
  • 1
  • 1
  • 8
  • in ```$run_price = mysqli_query($con,$sel_price);``` what is $con try to dump it – axel axel Jun 05 '19 at 08:15
  • 2
    How is JavaScript relevant to this issue? – VLAZ Jun 05 '19 at 08:16
  • Possible duplicate of [How to get MySQLi error information in different environments? / mysqli\_fetch\_assoc() expects parameter 1 to be mysqli\_result](https://stackoverflow.com/questions/22662488/how-to-get-mysqli-error-information-in-different-environments-mysqli-fetch-as) – Dharman Jun 05 '19 at 08:22

1 Answers1

-1

mysqli_query() returns FALSE in case of error. Check your query

Michael Krutikov
  • 462
  • 1
  • 5
  • 9