错误在$quant=mysql_result($quantity, 0);
$quantity=("SELECT product_qty_available FROM product WHERE product_id={$_POST['id']} ");
$quant=mysql_result($quantity, 0);
if($quant > $_POST['quant'])
{
echo "Input Quantity Exceeded!";
}
else
{
exit;
}
答案 0 :(得分:3)
那是因为你实际上并没有查询你的数据库。
$quantity=("SELECT product_qty_available FROM product WHERE product_id={$_POST['id']} ");
应该是
$quantity=mysql_query("SELECT product_qty_available FROM product WHERE product_id={$_POST['id']} ");
答案 1 :(得分:2)
试试这个>>
$quantity=mysql_query("SELECT product_qty_available FROM product WHERE product_id={$_POST['id']} ");
$quant = mysql_result($quantity, 0);
if (!$quant) {
die('Could not query:' . mysql_error());
}
if($quant > $_POST['quant'])
{
echo "Input Quantity Exceeded!";
}
else
{
exit;
}
答案 2 :(得分:1)
$quantity=mysql_query("SELECT product_qty_available FROM product WHERE product_id='"$_POST['id']."'") or die('Could not query:' . mysql_error());
// $quant = mysql_result($quantity);
if(mysql_num_rows($quantity) > $_POST['quant'])
{
echo "Input Quantity Exceeded!";
}
else
{
exit;
}
试试这个会起作用。