-3
Needed help to check if the quantity chosen by the customer is different from the existing stock
Code I am using
$con=mysqli_connect('localhost', 'root', '', 'pap') or die (mysqli_error ());
$strSQL1 = "SELECT 'QuantidadeProduto' FROM `produtos` WHERE `Id_Produto`=1";
$rs1 = mysqli_query($con,$strSQL1);
if(isset($_POST['verifica1'])){
$quantiade = $_POST['quantidade'];
}
if($quantiade>$rs1){
echo ("inferiror");
}
elseif ($quantiade<$rs1){
echo("Falta stock");
}
and is giving me the following mistakes
Warning: Use of Undefined Constant quantiade - assumed 'quantiade' (this will throw an Error in a Future version of PHP) in C: xampp htdocs Site pagina_produto.php on line 635
Warning: Use of Undefined Constant quantiade - assumed 'quantiade' (this will throw an Error in a Future version of PHP) in C: xampp htdocs Site pagina_produto.php on line 638
you lack the $ behind the quantity
– Ivónio
gives error in the same why tried without. gives the following error Notice: Undefined variable: quantiade in C: xampp htdocs Site pagina_produto.php on line 635
– José Gomes
in the comic you have the field "quantity" correct ?
– Ivónio
that quantity field is the number of items that is indicated by a select. In the database the field is called Quantityproduct
– José Gomes
Your error may be because the variable
$_POST['quantidade']
does not return anything, in this case its variable$quantiade
nor will be declared.– David Alves
but it returns the right value, ie the variable is declared
– José Gomes
if you echo in $rs1, it brings what?
– Diego
Modifies $quantity = $_POST['quantity']; for $quantity = $_POST['Quantityproduct'];
– Rafa
@Rafa gives error in the same -> Notice: Undefined index: Quantityproduct in C: xampp htdocs Site pagina_product.php on line 634 1Falta stockstdClass Object ( [name] => [def] => [db] => [Catalog] => def [max_length] => 17 [length] => 17 [charsetnr] => 8 [flags] => 1 [type] => 253 [decimals] => 31 )
– José Gomes
Check my answer in this case, use PDO, you can use this example to compare https://answall.com/questions/305092/contar-texto-equal-do-banco-data
– Rafa
People error is not because quantity is misspelled??? "Quanauntof"
– Leandro Angelo
No @Leandroangelo you name the variable you want
– José Gomes