Forum Moderators: open

Message Too Old, No Replies

Problem with SQl String

         

webboy1

3:05 pm on Sep 24, 2002 (gmt 0)

10+ Year Member



Hi,

I managed to get earlier problems fixed so thanks for everyones help.

Now i have a new problem.

What i am building is a page whereby the user types in there fullname and email and hits submit.

On submit 2 things happen,

1) The details are stored in a database

2) The user is taken to a bigger form where there name and email are auto filled.

The problem is that i cannot pull out the information from the Db into to the form.

I am trying to pull the data = to the session id that was sent from the first form....if that makes sense.

MY SQL string reads

"SELECT f_name, s_name, email from tbl_mytable WHERE session_id = <%request.form("session_id")%>"

But it does not work.

I can get it to work if i type:

"SELECT f_name, s_name, email from tbl_mytable WHERE session_id = 12345678"

12345678 being an example of an existing value in the session_id column.

Can anyone help?

webboy

Xoc

3:10 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need:

"SELECT f_name, s_name, email from tbl_mytable WHERE session_id =" & <%request.form("session_id")%>

Dreamquick

3:16 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Errm wouldnt that be;

"SELECT f_name, s_name, email FROM tbl_mytable WHERE session_id = " & Request.Form("session_id")

Assuming that the string is being assembled at the server side...

webboy1

3:34 pm on Sep 24, 2002 (gmt 0)

10+ Year Member



Cheers guys,

I have tried both but i am still having no luck.

I tried many variations but am still having no luck.

Any other ideas.

Webboy

JuDDer

3:47 pm on Sep 24, 2002 (gmt 0)

10+ Year Member



Is the first page redirecting to the second page or is the form being submitted to the second page?

If your page is redirecting after inserting a record, the following page cannot read from the form on the previous page.

If the page is redirecting after inserting, you may want to tag the session id as a querystring to pick up on the second page.

page2.asp?id=123465

and on page2.asp:

"SELECT f_name, s_name, email FROM tbl_mytable WHERE session_id = " & Request.QueryString("id")

webboy1

3:55 pm on Sep 24, 2002 (gmt 0)

10+ Year Member



My page is being submitted to a page.

I will try using redirect.

txbakers

4:00 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wouldn't use the SessionID as a variable in your DB. Better to create an autoincrement field with a unique ID number. The Session ID will change each time a user logs on. If you use a unique ID number, you can use cookies and remember that user.

If the above post doesn't work, take a look at your METHOD for the form. You might have to use Request.Form("session_id") instead.

Submitting will work, but the inserting will happen on the 2nd page, not the same page.

Xoc

9:32 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yup, wasn't thinking. Correct syntax given in the later posts.