On Wed, 3 Oct 2001 17:35, Daniel Alsén wrote: > Hi, > > i need help with a, seemingly, simple problem... > > I have a form that is supposed to update a MySql table with only two > fields (id and show_id). I use show_id to determine what is showing on > my first page and never store more than one value in the table. > > Now - i cant seem to get the REPLACE to work. First it only added more > rows in the table with a new value each time. I solved that by > inserting I inserted a hidden value into the form to make sure that the > correct (and only) value will be replaced: > > <input type="hidden" name="fid" value="1"> > > But, that´s when it stopped working. > Show_id is determined by radio buttons in the form and that part is > working. In the actual query i REPLACE the value of show_id: > > $query = "REPLACE INTO puff"; > $query .= "(id, show_id)"; > $query .= " values('$fid''$show_id')"; > > I am sure it´s a simple solution. But please point it out for me.
A quick look at the REPLACE syntax tells me that "REPLACE works exactly like INSERT, except that if an old record in the table has the same value as a new record on a unique index, the old record is deleted before the new record is inserted." So if id isn't a unique index, you could expect the values to be added. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Multitasking = 3 PCs and a chair with wheels! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]