MySQL Forums
Forum List  »  PHP

Re: php foreach and mysql update for an array from a form
Posted by: S
Date: February 07, 2006 06:30PM

I added in a echo mysql_errno() . ": " . mysql_error() line and here's what came out:

Array ( [0] => Array ( [accept] => no [ID] => 20060207162631 ) [1] => Array ( [accept] => yes [ID] => 20060207142301 ) [2] => Array ( [accept] => yes [ID] => 20060207124426 ) [3] => Array ( [accept] => yes [ID] => 20060207124327 ) )
ID: 20060207162631 Approve: no
update successful.
UPDATE comments SET Approved='no' WHERE timestamp='20060207162631' LIMIT 1;

ID: 20060207142301 Approve: yes
update NOT successful.
UPDATE comments SET Approved='yes' WHERE timestamp='20060207142301' LIMIT 1;
1062: Duplicate entry '20060207172340' for key 1

ID: 20060207124426 Approve: yes
update NOT successful.
UPDATE comments SET Approved='yes' WHERE timestamp='20060207124426' LIMIT 1;
1062: Duplicate entry '20060207172340' for key 1

ID: 20060207124327 Approve: yes
update NOT successful.
UPDATE comments SET Approved='yes' WHERE timestamp='20060207124327' LIMIT 1;
1062: Duplicate entry '20060207172340' for key 1

Update Complete!

...So... it looks like its using the same key for each update command. (honestly, I have no idea what that means)

the field "timestamp" is an actual timestamp and I would like it to be static once the initial entry is made in the table. Every time I run the query to update information, it changes the timestamp... Ideas on how to keep that static?

Much appreciated.

---S

Options: ReplyQuote


Subject
Written By
Posted
Re: php foreach and mysql update for an array from a form
S
February 07, 2006 06:30PM
S
February 08, 2006 07:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.