Reply to Re: How to "fetch" a certain id

Your name:

Reply:


Posted by Kimmo Laine on 11/17/06 08:30

"Bart op de grote markt" <bartwarnez@freegates.be> wrote in message
news:1163750936.843742.247280@h48g2000cwc.googlegroups.com...
> Jeff North schreef:
>
>> On 16 Nov 2006 18:07:37 -0800, in comp.lang.php "casper christensen"
>> <tjenpengemensdusover@gmail.com>
>> <1163729257.158721.161250@e3g2000cwe.googlegroups.com> wrote:
>>
>> >| Hi
>> >|
>> >| When someone fills the form on my site, and id is created in my
>> >| database. (see below)
>> >|
>> >| http://www.affiliatesjunction.net/directory.php?ax=out&id=XXX
>> >|
>> >| after submitting the form they are directed to a "thank you page". Now
>> >| I need to show the above link in a textfield with the newly created
>> >id.
>> >|
>> >| How can I "fetch" this id from the database.?
>> >|
>>
>> I presume that id is a primary key with auto_increment.
>>
>> Once you've saved the record use last_insert_id() to return the newly
>> inserted PK. Then you can redirect to your next page using that
>> information.
>
> Just wondering, is that safe? More than one person can subscibe at the
> same time. Can't one get the wrong id then?

No, if the last insert id is called during the same connection. It works per
connection, even if there are two concurrent connections, the function
returns the id that was inserted during that particular connection, the
other connection does not affect even if it does insert another record at
the same time. This applys at least to mysql's mysql_insert_id() function,
and possibly to other rdbm's as well.

>
> Why not use sessionvariables for the information u want to transfer?
>

Yes, it can be done with session, but a session requires a cookie, and not
everyone allows cookies. Cookies, we don't need no stinkin' cookies. Just
put it in the url and it works for sure...

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)

[Back to original 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация