Page 1 of 1

Query to add data to table works first time, but not again.

Posted: Thu Nov 18, 2004 12:27 pm
by dardsemail
Hi,

I have a little snippet of code - seems like it should be so easy - to add items to a table. When I run the code the first time, it works perfectly, but then if I try it a second time - nothing is added to the table.

Here's the code:

Code: Select all

$addBidQuery = ("INSERT INTO bids_tb(bidNum, userID, itemNum, bid) VALUES('$bidNum','".$_SESSIONї'userID']."','$itemNum','$bid')") OR DIE(mysql_error());
	$addBidResult = mysql_query($addBidQuery);
Here's the command line that is generated:
INSERT INTO bids_tb(bidNum, userID, itemNum, bid) VALUES('27134838192738839842','54','3','1000.00')
I can't figure out what the heck is going on! I've never had this problem before.

Can anyone give me any suggestions as to how to resolve it?

Thanks!

Posted: Thu Nov 18, 2004 12:49 pm
by dardsemail
Never mind - it was a problem with the way my database table was set up.

Posted: Thu Nov 18, 2004 12:50 pm
by kettle_drum
You probably have some fields set up to hold unique data only, and so when you try and post the same data a second time it doesnt let you as the data is duplicated.