0
这里是我的查询MySQL的插入查询变量发出
// Put it all into the database
mysql_query("INSERT INTO
orders (
item_id,
order_id,
contact_first_name,
contact_last_name,
contact_email,
contact_phone,
business_name,
business_type,
business_website,
business_address,
business_city,
business_state,
business_zip,
business_phone,
promo_code,
add_details
)
VALUES(
". $post_data['item_id'] .",
". $order_hash .",
". $post_data['contact_first_name'] .",
". $post_data['contact_last_name'] .",
". $post_data['contact_email'] .",
". $post_data['contact_phone'] .",
". $post_data['business_name'] .",
". $post_data['business_type'] .",
". $post_data['business_website'] .",
". $post_data['business_address'] .",
". $post_data['business_city'] .",
". $post_data['business_state'] .",
". $post_data['business_zip'] .",
". $post_data['business_phone'] .",
". $post_data['promo_code'] .",
". $post_data['add_details'] ."
)
") or die(mysql_error());
现在如果我填写的所有表格,以便有没有空字符串它给了我这个错误。哈希是$ order_hash:
未知列在“字段列表” 76a051b750ce9363cec3df9961d2fd6b“
如果我留一些空白,则它给了我:
你有一个错误的SQL语法;检查 对应于你的MySQL服务器版本的手册正确的语法使用双引号 接近“1,,,,AL,,,,)”在第27行
我曾尝试多种变化,单引号等等,似乎无法弄清楚。这应该是一个简单的插入查询,就像我之前做的一样,但我只是用这个运行一个垃圾。感谢您的帮助:)
THANK YOU!那么有没有一个混乱的方式,或者我只是错过了单引号? – MLM 2012-04-06 05:18:53
你只是错过了单引号,也确保你在引用之前过滤数据,以避免SQL注入 – safarov 2012-04-06 05:20:19
是的,我已经过滤上面,我只是有一个干净的数组插入之前。再次感谢 ;) – MLM 2012-04-06 05:21:14