我正在尝试使用 PHP 和 Mysql 进行 INSERT INTO。
这是在 PHPMyadmin 中成功的 SQL 语句:
INSERT INTO purchase_orders VALUES (
DEFAULT,
'501',
'80999',
'149179',
'EB-0408898',
'1',
'Thompson Center Barrel Encore 26\" Stainless Steel Fluted 35 Whelen 4767',
'294.43',
'4767',
'UPS Ground',
'11.61',
'LA',
'P',
'1',
'264.99',
DEFAULT,
DEFAULT
)
这是我运行 SQL 的 PHP 语句:
$sql = "INSERT INTO purchase_orders VALUES (
DEFAULT,
'".mysql_real_escape_string($po_num)."',
'".mysql_real_escape_string($order_id)."',
'".mysql_real_escape_string($product_id)."',
'".mysql_real_escape_string($product_code)."',
'".mysql_real_escape_string($amount)."',
'".mysql_real_escape_string($product)."',
'".mysql_real_escape_string($price)."',
'".mysql_real_escape_string($mfg_code)."',
'".mysql_real_escape_string($shipping_method)."',
'".mysql_real_escape_string($shipping_cost)."',
'".mysql_real_escape_string($s_state)."',
'".mysql_real_escape_string($status)."',
'".mysql_real_escape_string($dist_code)."',
'".mysql_real_escape_string($dist_cost)."',
DEFAULT,
DEFAULT)";
mysql_query($sql, $dbc);
echo mysql_errno($dbc) . ": " . mysql_error($dbc). "\n";
我完全困惑为什么插入语句不适用于 PHP。
我也尝试过这个 SQL 代码,结果相同......
INSERT INTO purchase_orders(po_num, order_id, product_id, product_code, amount, product, price, mfg_code, shipping_method, shipping_cost, s_state, status, dist_code, dist_cost) VALUES ('501','80999','149179','EB-0408898','1','Thompson Center Barrel Encore 26\" Stainless Steel Fluted 35 Whelen 4767','294.43','4767','UPS Ground','11.61','LA','P','1','264.99')