problem with duplicated row saved in mysql table
there is a old mysql problem for me that i couldnt solve and its saving duplicated empty row in some mysql tables
this is my table structure : when im trying to query like this :
$db->sql_query("INSERT INTO `table_donate` values (`did`,`name`,`username`,`user_email`,`donate_amount`,`donate_time`,`reveal_info`,`reason`) , (NULL,'".$info[name]."','".$info[username]."'开发者_开发技巧,'".$info[user_email]."','".$price."','".$ctime."','1','$reason')"
) or die(mysql_error());
simply two rows saved after running above query
I wonder how can I fix this problem !?!
Is this what you are trying to do:
INSERT INTO `table_donate` (`did`,`name`,`username`,`user_email`,`donate_amount`,`donate_time`,`reveal_info`,`reason`)
values (NULL,'".$info[name]."','".$info[username]."','".$info[user_email]."','".$price."','".$ctime."','1','$reason')
You need to put the table columns, before the values
sign. Mysql will try to insert everything afterwards.
Alternatively, if you are inserting data into every column, you don't need the column names in the first place.
Anything in parenthesis that comes after VALUES
will be inserted. You have two ()
lists of items to insert separated by a comma, so two rows are inserted.
The syntax for an INSERT
statement in MySQL is
INSERT INTO table (col1, col2, ...) VALUES (val1, val2, ...)
Instead of what you have now, try
$db->sql_query("INSERT INTO `table_donate` (`did`,`name`,`username`,`user_email`,`donate_amount`,`donate_time`,`reveal_info`,`reason`) values (NULL,'".$info[name]."','".$info[username]."','".$info[user_email]."','".$price."','".$ctime."','1','$reason')") or die(mysql_error());
精彩评论