You are here: Re: mySQL, Best Way to Increment Records « All PHP « IT news, forums, messages
Re: mySQL, Best Way to Increment Records

Posted by J.O. Aho on 09/28/56 11:46

Rik wrote:
> number1.email@gmail.com wrote:

>> Problem is, what if someone also
>> requests this same userid before I "insert" my record?
>
> Why would thid happen? It seems to me this is not a database problem but a
> code problem.

It would happen if he writes his scripts to fetch the highest ID-value from
the table and in php does a $ID++ and then makes the INSERT and then two
persons would register themselves at the "same time", only one would be
registered and the other would get an error message as that one was trying to
create a user with the same ID-number.

Of course this is a code problem and the mysql AUTO_INCREMENT will fix if the
INSERT is made without trying to set an ID, "INSERT INTO
users(Name,Login,Password) VALUES('Joe Doe','Joe','Doe')" in a table with the
columns ID,Name,Login,Password, where Id had the AUTO_INCREMENT set.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация