473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to "fetch" a certain id

Hi

When someone fills the form on my site, and id is created in my
database. (see below)

http://www.affiliatesjunction.net/di...?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.?

casper
..

Nov 17 '06 #1
9 2087
On 16 Nov 2006 18:07:37 -0800, in comp.lang.php "casper christensen"
<tj************ ******@gmail.co m>
<11************ **********@e3g2 000cwe.googlegr oups.comwrote:
>| Hi
|
| When someone fills the form on my site, and id is created in my
| database. (see below)
|
| http://www.affiliatesjunction.net/di...?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.
---------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Nov 17 '06 #2
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 sessionvariable s for the information u want to transfer?

Bart

Jeff North schreef:
On 16 Nov 2006 18:07:37 -0800, in comp.lang.php "casper christensen"
<tj************ ******@gmail.co m>
<11************ **********@e3g2 000cwe.googlegr oups.comwrote:
| Hi
|
| When someone fills the form on my site, and id is created in my
| database. (see below)
|
| http://www.affiliatesjunction.net/di...?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.
---------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Nov 17 '06 #3
"Bart op de grote markt" <ba********@fre egates.bewrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Jeff North schreef:
>On 16 Nov 2006 18:07:37 -0800, in comp.lang.php "casper christensen"
<tj*********** *******@gmail.c om>
<11*********** ***********@e3g 2000cwe.googleg roups.comwrote:
>| Hi
|
| When someone fills the form on my site, and id is created in my
| database. (see below)
|
| http://www.affiliatesjunction.net/di...?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 sessionvariable s 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
sp**@outolempi. net | rot13(xv***@bhg byrzcv.arg)
Nov 17 '06 #4
Well, I guess you Gurus are right:) but I don't realy know how to do
what you just wrote.

Can anyone give an example on how the code should look?

Casper

Nov 17 '06 #5
casper christensen wrote:
Well, I guess you Gurus are right:) but I don't realy know how to do
what you just wrote.

Can anyone give an example on how the code should look?
....
$db = new mysqli(/* db connect params */);
$res = mysqli->query("inser t into foo values /* whatever */");
// check for error
$res = mysqli->query("selec t last_insert_id( )");

then parse the resulting object out as any mysqli result.

/Marcin
Nov 17 '06 #6
Message-ID: <11************ *********@e3g20 00cwe.googlegro ups.comfrom
casper christensen contained the following:
>Well, I guess you Gurus are right:) but I don't realy know how to do
what you just wrote.

Can anyone give an example on how the code should look?
I think what Kimmo means is that you need to find whatever code
redirects to the thank you page and pass the id along with it.

The trouble is, we don't know if this is the correct scenario. It may
be that the code to insert the data is in the thank you page. The way
to check is to look at the form tag and see where it points.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Nov 17 '06 #7
I have used this code to go from the form to thank you page:

// redirect to "thank you" page
header('Locatio n:
http://www.affiliatesj unction.net/linkadded.php') ;
exit(0);

There is alot of coding about mysgl and $_post -stuff. Now the id
created is just an incresement from the following id.

Here is the site I want the link (id) to appear on (look in the
textfield):

http://www.affiliatesjunction.net/te...edTemplate.php

casper

Nov 17 '06 #8
Bart op de grote markt wrote:
Jeff North schreef:

>>On 16 Nov 2006 18:07:37 -0800, in comp.lang.php "casper christensen"
<tj********** ********@gmail. com>
<11********** ************@e3 g2000cwe.google groups.comwrote :

>>>| Hi
|
| When someone fills the form on my site, and id is created in my
| database. (see below)
|
| http://www.affiliatesjunction.net/di...?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 .
---------------------------------------------------------------
jn******@your pantsyahoo.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 sessionvariable s 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.
js*******@attgl obal.net
=============== ===
Nov 17 '06 #9
>
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.

Of course I don't expect to put the id in a session variable. That is
not what I said, is it...

Nov 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1843
by: Kai Grossjohann | last post by:
On unload of a page, I store the current scrollbar position (ie, window.pageXOffset and window.pageYOffset) into a cookie. On load of that same page, I fetch the information from that cookie and scroll the window accordingly. I used the name "remember_scrolling" for the function doing the store, and "recall_scrolling" for the function doing the fetch. (There is also a function which deletes the cookie. It is named "forget_scrolling".)
5
3261
by: Bob Sparks | last post by:
I upgraded to stinger and got stung. Not all my code compiles. Most of the problems are stinger seems to be more stringent on casting varchars to vargraphics. This I am working out, however, one procedure fails to compile and gives the following message. SQL0901N The SQL statement failed because of a non-severe system error. Subsequent SQL statements can be processed. (Reason "Can not enforced Maxcard > 1".) LINE NUMBER=67....
7
2481
by: sunglo | last post by:
My doubt comes from trying to understand how thread return values work (I know, it's off topic here), and I'm wondering about the meaning of the "void **" parameter that pthread_join expects (I think this is topical, since it's a C question, but please correct me and apologies if I'm wrong). I suppose that it's this way to allow for "generic" pointer modification, but this implies dereferencing the "void **" pointer to get a "void *"...
1
1875
by: Bernd Hohmann | last post by:
I have a question about using "*" in (sub)queries. This example query counts the number of records for a certain customer starting with record "80172" and stops after 10 rows. SELECT PK_ORDER,PK_CUSTOMER FROM (SELECT PK_ORDER,PK_CUSTOMER, ROW_NUMBER() OVER() AS rn FROM CUSTOMER_ORDERS_HD WHERE PK_CUSTOMER='10649' ORDER BY PK_ORDER DESC) AS T2 WHERE T2.rn <= 80172 FETCH FIRST 10 ROWS ONLY
7
14659
by: John Layton | last post by:
Hi there, Is it possible to pass null to a function taking an "out" (or "ref") parameter in C#. I'd like to do something like the following (which doesn't compile of course). Thanks in advance. int SomeValue; Func(null, SomeValue); // Any way to pass null for either arg? void Func(out int Param1, out int Param2)
10
4791
by: craig.keightley | last post by:
I am trying to get the next row within a loop for a script i am developing... I need to display a final table row within the table that i have displayed on the page, but i only want to show it if value of the current field is not the same value of the next row. eg:
0
3974
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete some values while leaving the other values alone. I am designing this database/table/column so maybe I could use attributes or elements/nodes, the choice is ultimately mine. The one constraint is that I have to allow for customized name/value pairs....
3
13240
by: Rahul Babbar | last post by:
Hi, I had the following doubts about the "For Read Only" clause. 1. How does a "for Read only" clause improve the performance? 2. How does a "for Read only" clause compare with "With UR" clause in performance? Which is faster? Can someone clarify on that?
0
1975
by: CatchSandeepVaid | last post by:
Product and ProductBasic has one-to-one relationship Product ---> ProductID <<PK>> ProductBasic ----> ProductId, useCode, StartTime as composite key..... this startTime's value will be known as runtime. Now i want to define mapping between Product & ProductBasic, how will i do it ? Moreover suppose i define their mapping as product.productID = productBasic.productID and useCode='a' as :
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.