$a=$_POST['stock']; $b=$_POST['qty']; $c=$a+$b; echo $c; When i execute this i get this error A non numeric value encoutered | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

$a=$_POST['stock']; $b=$_POST['qty']; $c=$a+$b; echo $c; When i execute this i get this error A non numeric value encoutered

Even i use intval() for the two vatiables When i put stock=1 qty=1 Output of c:1 What's the problem

15th May 2020, 6:37 AM
Thimma Chowdary
Thimma Chowdary - avatar
3 Answers
+ 1
$_POST isn't a numeric value i suppose.
15th May 2020, 6:52 AM
yochanan sheinberger
yochanan sheinberger - avatar
0
When i convert to intval($a) Intval($b) Input Stock:2 Qty:1 Output: 1 First variable value is taking to zero What might be proble..
15th May 2020, 6:58 AM
Thimma Chowdary
Thimma Chowdary - avatar
0
Print value of <$a> and <$b> before anything, see whether they contain valid data for addition into <$c>. Even better print value of $_POST["stock"] and $_POST["qty"] to be more convinced.
15th May 2020, 7:22 AM
Ipang