You are here: Re: How to "fetch" a certain id « PHP Programming Language « IT news, forums, messages
Re: How to "fetch" a certain id

Posted by Jerry Stuckle on 11/17/06 12:37

Bart op de grote markt wrote:
> 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.
>>---------------------------------------------------------------
>>jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
>>---------------------------------------------------------------
>
>
> Just wondering, is that safe? More than one person can subscibe at the
> same time. Can't one get the wrong id then?
>
> Why not use sessionvariables for the information u want to transfer?
>
> Bart
>

(Top posting fixed)

Yes, it is perfectly safe. The returned value is the id of the last
insert for that connection.

As for using session variables - you're talking apples and oranges. How
do you expect to get the id to store it in the session variable? That's
what mysql_insert_id() is for. Once you get the id you can place it in
a session variable, store it someplace else or whatever you want.

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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