TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   MySQL & Databases (http://www.talkphp.com/mysql-databases/)
-   -   What is causing Duplicate Entries (http://www.talkphp.com/mysql-databases/4796-what-causing-duplicate-entries.html)

buildakicker 07-29-2009 08:08 PM

What is causing Duplicate Entries
 
Hi all,

I have simple form that puts data into a DB table. For some reason, it always gives me two entires. I cannot find why it would do that in the code anywhere. Here's my snipit:


PHP Code:

if(isset($_POST['go'])){
   
$atitle   =    mysql_real_escape_string($_POST['articleTitle']);
   
$abody =    mysql_real_escape_string($_POST['articleBody']);
   
$acategory =    mysql_real_escape_string($_POST['articleCategory']);
   
$atags =    mysql_real_escape_string($_POST['articleTags']);
   
$aauthor =    mysql_real_escape_string($_POST['articleAuthor']);   
   
$alink =    mysql_real_escape_string($_POST['articleLink']);
   
   
   if(!
get_magic_quotes_gpc())
   {
      
$atitle   addslashes($atitle);
      
$abody   addslashes($abody);
      
$atags   addslashes($atags);
   }
   include 
'config.php';
   include 
'opendb.php';

   
$query " INSERT INTO jf_posts (title,bodytext,category,tags,author,link) ".
            
" VALUES ('$atitle', '$abody', '$acategory', '$atags', '$aauthor', '$alink')";
   
mysql_query($query) or die('Error ,query failed');

   include 
'closedb.php';

   echo 
"<div id='topbar' align='center'>Article '$title' added!</div>";



adamdecaf 07-29-2009 11:27 PM

Does closedb.php contain a mysql_query()?

tony 07-30-2009 02:50 AM

i am guessing there is something in the includes files (specially closedb.php) that might be accessing the same $query variable to make a query.

Sam Granger 07-30-2009 02:29 PM

Either what has already been said, or double clicking of button, maybe even using back button. Do you always get duplicate entries?

buildakicker 07-30-2009 03:23 PM

I feel like an idiot. You guys are on it. I do have a query in closedb.php... bah!

Thanks for replying!

tony 07-30-2009 04:00 PM

happens to the best of us ... (personal experience)


All times are GMT. The time now is 07:52 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0