Mysql,插入数据时出错

时间:2012-02-21 05:40:57

标签: php mysql

变量不为null,我在查询顶部验证,但是我收到错误。 该脚本有效但现在,我收到此错误,请帮助,谢谢。

mysql_query("INSERT INTO proads_users (email,username,facebook_user,facebook_uid,reg_date,approved,active,account_id,account_last_payment,account_next_payment,payment_mode,balance,max_credit,salt,country,shop_account_id,shop_active,state,payment_status,shop_name,mail_activated,setting_quantity_number,name,address,city) 
VALUES('$email','$uzernaim','1','$user','$timeme','1','1','2','$timeme','0','2','0.00','0.00','a3bc4re','2002','4','1','234','confirmed','$uzernaim','1','1','$name','Default','Default'") or die("Error: ".mysql_error());

我收到此错误: 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在''

附近使用正确的语法

3 个答案:

答案 0 :(得分:2)

替换

,'Default'")

,'Default')")
你忘了关闭括号

答案 1 :(得分:1)

查询中缺少关闭括号“)”'默认')“

mysql_query("INSERT INTO proads_users (email,username,facebook_user,facebook_uid,reg_date,approved,active,account_id,account_last_payment,account_next_payment,payment_mode,balance,max_credit,salt,country,shop_account_id,shop_active,state,payment_status,shop_name,mail_activated,setting_quantity_number,name,address,city) 
VALUES('$email','$uzernaim','1','$user','$timeme','1','1','2','$timeme','0','2','0.00','0.00','a3bc4re','2002','4','1','234','confirmed','$uzernaim','1','1','$name','Default','Default')") or die("Error: ".mysql_error());

答案 2 :(得分:-1)

您的代码容易受到SQL注入攻击;考虑使用prepared statements重写您的查询。 可能错误是由$email$name或其他包含引号的变量引起的。