The following code cannot pass the variables: productname and price
It shows the error:
QTY: Image: Product: Price: Error, insert temp query failed. Data truncated for column 'qty' at row 1
<?php
include "database.php";
session_start();
if(isset($_POST['add']))
{
$query="select sum(qty) as yb from inventory where pid='$productname'";
$result = mysql_query($query) or die('Error, sum(qty) query failed. ' . mysql_error());
while($row = mysql_fetch_array($result))
{
list($yb) = $row;
$s=$yb;
}
$im = $productname . ".jpg";
echo " QTY: " . $s . " Image: " . $im . " Product: " . $productname . " Price: " . $price;
$query1 = "insert into temp (image, productname, qty, price) values ('$im', '$productname', '$s', '$price')";
mysql_query($query1) or die('Error, insert temp query failed. ' . mysql_error());
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF; ?>">
Product<input type="text" id="productname" name="last_productname" size="20" />
Price<input type="text" id="price" name="last_price" size="10" />
<input type="submit" value="add" name="add" />
</form>
</body>
</html>