insert adding double entries

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pixienick
Forum Newbie
Posts: 12
Joined: Sun May 28, 2006 6:58 pm

insert adding double entries

Post by pixienick »

Hi all
I am getting strange behaviour from an insert statement to a simple table. I insert like;

Code: Select all

$InsertFav = "INSERT INTO favourites VALUES($AdID,$inID, 1,'')";
It keeps adding two records instead of one! At first it didnt have a unique id so i added one and it still adds two records with unique ids. I tried to hack around it deleting a record after with

Code: Select all

$delID = mysql_insert_id();
					
$deleteExtraFav = "DELETE FROM favourites WHERE id=$delID";
But that deletes 2 records too!
What am i doing?
Any help or advice much appreciated.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Check your mysql log file... Usually this is due to some redirection in a script, which results in the fact that a script is executed twice...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you add an echo statement just before or after the mysql_query() call you would be able to see if this was duplicated too. Check any loops the query is nested within.

Mac
pixienick
Forum Newbie
Posts: 12
Joined: Sun May 28, 2006 6:58 pm

Post by pixienick »

yeah i tried outputting text but that gave me no clues. Where might i find this mysql error log?
Cheers
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

try printing http referers from server variables.
Post Reply