MySQL/PHP两次插入同一行 [英] MySQL/PHP Inserting the same row twice
问题描述
请帮助.我认为自己对MySql& PHP,但是对于我来说,我无法弄清楚为什么这段代码两次插入同一行.我从字面上将其剥离回以下代码:
Please help. I consider myself to have a reasonable understanding of MySql & PHP, but for the life of me I can't figure out why this code is inserting the same row twice. I've literally stripped it back to the following code:
<?php
$query = "INSERT INTO `cs_social_alerts` (email) VALUES ('test@test.com')";
mysql_query($query);
?>
要插入的MySQL表中有10列,但是即使查询中提到了所有这些列,它仍会在两行中使用单独的主键插入"test@test.com".
The MySQL table it's being inserted into has 10 columns in it, but even with all of them mentioned in the query, it still inserts 'test@test.com' on two rows, with separate primary keys.
我创建了一个新的Wordpress页面来运行此页面,因为所有其他页面在没有重复的情况下都可以正常运行.
I've created a new Wordpress page to run this on as all other pages seem to be functioning fine without the duplication.
我已经完成了一些Google搜索,但并没有太多帮助-无论如何,我可以检查第二个查询的来源吗?我已经看了上面的代码约一个小时了,看不到任何问题.
I've done some Googling which hasn't found much of any help - Is there anyway I can check where the second query is coming from? I've starred at the above code for about an hour now and cannot see any issues with it.
任何想法/帮助都非常感谢!
Any ideas/help MUCH appreciated!
谢谢
-----编辑-----
----- EDIT -----
所以这是调试回溯的结果,正在运行的代码实际上是上面的两行-为了安全起见,我将域空白了.有人可以看到任何干扰吗?我不是PHP专家,并且所有其他多余的Wordpress东西都扔进了我,我不确定这是什么!谢谢你们
So here's the result from the debug traceback, the code that's being run is literally the 2 lines above - I've blanked the domain for security. Can anyone see any interference? I'm no PHP expert and with all the extra Wordpress stuff thrown in, I'm not sure what's what! Thanks guys
$ myQuery ="INSERT INTO cs_social_alerts
(email)VALUES('test@test.com')";
$myQuery = "INSERT INTO cs_social_alerts
(email) VALUES ('test@test.com')";
mysql_query($ myQuery);
mysql_query($myQuery);
debug_print_backtrace()
debug_print_backtrace()
?>
)在[/var/sites/c/****.com/public_html/wp-content/plugins/wp-exec-php/wp-exec-php.php:692]中调用
) called at [/var/sites/c/****.com/public_html/wp-content/plugins/wp-exec-php/wp-exec-php.php:692]
$ myQuery ="INSERT INTO cs_social_alerts
(email)VALUES('test@test.com')";
$myQuery = "INSERT INTO cs_social_alerts
(email) VALUES ('test@test.com')";
mysql_query($ myQuery);
mysql_query($myQuery);
debug_print_backtrace()
debug_print_backtrace()
?>
)
$ myQuery ="INSERT INTO cs_social_alerts
(email)VALUES('test@test.com')";
$myQuery = "INSERT INTO cs_social_alerts
(email) VALUES ('test@test.com')";
mysql_query($ myQuery);
mysql_query($myQuery);
debug_print_backtrace()
debug_print_backtrace()
?>
))在[/var/sites/c/*.com/public_html/wp-includes/plugin.php:192]中调用
)) called at [/var/sites/c/*.com/public_html/wp-includes/plugin.php:192]
$ myQuery ="INSERT INTO cs_social_alerts
(email)VALUES('test@test.com')";
$myQuery = "INSERT INTO cs_social_alerts
(email) VALUES ('test@test.com')";
mysql_query($ myQuery);
mysql_query($myQuery);
debug_print_backtrace()
debug_print_backtrace()
?>
推荐答案
我遇到了同样的问题,这是Chrome错误! 我清除了会话,Cookie,缓存,所有数据应用程序,并且它们都可以正常工作.
I had the same problem, and it was chrome fault! I clear the sessions, cookies, cache, all data application and it works.
这篇关于MySQL/PHP两次插入同一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!