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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

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

Post 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!
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

Post by dardsemail »

Never mind - it was a problem with the way my database table was set up.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
Post Reply