[英]phpMyAdmin won't allow a numbers into decimal?
所以我的代碼:
$productname = $_GET['productname'];
$productprice = $_GET['productprice'];
$productimage = $_GET['productimage'];
$productcat = $_GET['cat'];
$query = "INSERT INTO $tbl_name ('name, img, price, category') VALUES ('$productname, $productimage, $productprice, $cat')";
mysql_query($query);
$ productprice = 1.99,phpMyAdmin上的類型設置為十進制(2,2)。 當查詢運行時,它不會放在數據庫中。 我厭倦了在返回的數據庫上以SQL運行;
SQL查詢:
INSERT INTO products( name, img, price, category )
VALUES (
black pens, 007.jpg, **1.99**, stationary
)
MySQL說:文檔
1064-您的SQL語法有誤; 檢查與您的MySQL服務器版本相對應的手冊以獲取正確的語法,以在第1行的“ pens,007.jpg,19,平穩)附近使用
問題出在字符串數據之前。 應引用:
INSERT INTO products( name, img, price, category )
VALUES (
'black pens', '007.jpg', 1.99, 'stationary'
)
從查詢中刪除單引號
$query = "INSERT INTO $tbl_name (name, img, price, category) VALUES ($productname, $productimage, $productprice, $cat)";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.