jaikob Posted October 11, 2008 Share Posted October 11, 2008 php is inserting the same row twice into mysql. I don't know why, and its starting to make me mad because the rest of my site doesn't do this. I've remade the database table twice, and stripped my code down. Here is my code: <?php $add_product = $_GET['prod_id']; $add_qty = $_GET['qty']; $add_ip = $_SERVER['REMOTE_ADDR']; mysql_connect("localhost", "root", "HIDDEN PASSWORD") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); mysql_query("INSERT INTO app_cart (prod_id, uid, qty, ip_addr) VALUES('$add_product', '0', '$add_qty', '$add_ip' ) ") or die(mysql_error()); ?> My DB is as follows: id --> INT --> PRI KEY --> Auto Increment prod_id --> INT uid --> INT NULL qty --> INT ip_addr --> varchar 1000 Any insight? I'm clueless. Quote Link to comment https://forums.phpfreaks.com/topic/128036-solved-mysql-inserting-data-two-times/ Share on other sites More sharing options...
Guest Posted October 11, 2008 Share Posted October 11, 2008 All in all, the core code itself doesnt seem at fault. It's like a problem in how the script is invoked. There are any number of things to look for unfortunately, from javascript refresh/redirects, to header redirects, to the user clicking the link more than once. Do you have a debugger? Or use an IDE with one? It could easily tell you where the problem starts. Quote Link to comment https://forums.phpfreaks.com/topic/128036-solved-mysql-inserting-data-two-times/#findComment-663021 Share on other sites More sharing options...
jaikob Posted October 11, 2008 Author Share Posted October 11, 2008 You where right. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/128036-solved-mysql-inserting-data-two-times/#findComment-663043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.