-2

I am running a PHP script, and keep getting errors like: Notice: Undefined variable: price in C:\xampp\htdocs\alenayahpharmacy\cart.php on line 128

Warning: A non-numeric value encountered in C:\xampp\htdocs\alenayahpharmacy\cart.php on line 129

Line 128 and 129 looks like this:

$pricetotal=$price*$each_item['quantity'];              
$carttotal=$pricetotal+$carttotal;
  • 1
    Please add more details about your problem and your own efforts this far to solve the problem so that people can help you better. Read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – pirho Nov 15 '17 at 08:00
  • 1
    "Undefined variable: price" I mean it is clear enough what is the issue isn't it ? – Pain67 Nov 15 '17 at 08:05
  • 1
    These error's are pretty clear right? `$price` does not have a value set to it and `$pricetotal` or `$carttotal` have a non-numeric value. What is your problem? – Mark Baijens Nov 15 '17 at 08:08
  • Yes $price does not contain any value, that's why such error comes. – Amit Gupta Nov 15 '17 at 08:09
  • Please show more code, especially where your variables are initialized. – Raimund Krämer Nov 15 '17 at 08:30
  • $sql=mysqli_query($con,"select * from product_details where product_code='$item_id' limit 1"); while($row=mysqli_fetch_array($sql)) { $productname=$row['product_name']; $productcode=$row['product_code']; $price=$row['product_price']; $img=$row['product_img']; } – ABDUR REHMAN Nov 15 '17 at 08:57

1 Answers1

1

It simply means $price does not exist and therefore its null which leads to the second error.

Manuel Mannhardt
  • 2,191
  • 1
  • 17
  • 23