Re: Re: Update creating a new record?

From: Date: Tue, 06 Aug 2002 00:08:20 +0000
Subject: Re: Re: Update creating a new record?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111300@lists.php.net to get a copy of this message
> >I've noticed that every time I "update" a record, mySQL is actually adding a > >new record (highest number ID, at the end) and deleting the original record. > >I don't understand this. For example, if I edit a phone number in the > >listing for ID=023, the next time I view a complete listing of members I'll > >see that person's link now showing ID=128 (or a similar much higher record > >number, 1 higher than the last highest record number). My PHP code uses > >"upate photographers" to update rather than insert a new record. I can post > >the actual code tonight if needed, but I was hoping that someone might have > >an idea of whether or not this was normal. It DOES pull up the right data > >after I update mySQL, but it's the change in the link that bites me on one > >other page with hard-coded links. > > Show us source. > > Update should not alter their ID, unless, like, you actually *ASKED* it > to... > > UPDATE foo set ID = 128 where ID = 023 > > would do exactly what you describe... > > Try echo-ing out your query before you send it to the database, and see what > you are actually saying to MySQL, as opposed to what you *think* you are > saying to MySQL... :-) Maybe you are UPDATING your column to NULL? The only way I could possibly imagine this happening is if you were doing something like UPDATE your_table SET ID = NULL, ... On an INSERT, that would get you the next auto_incremented ID, but I don't know about an UPDATE. Odds are it's something really stupid and easy to figure out...but a lot of times we get caught up in the code and miss it. :) ---John Holmes...

« previous php.general (#111300) next »