View Full Version : Struggling with an error!

06-19-2006, 01:37 AM
Hi there
I have a 3 page registration form where a user can regsiter for an online service. Page 1 gathers personal info and page 2 gathers services desired.

In page one I have an INSERT script to input all the data. In page 2 of the registration I have a $_SESSION that grabs the ID created from page 1 and then instead of an INSERT script I have an UPDATE script to update the additional fields needed for the user.

So, when you click on "next" of page 1 of the registration form everything works fine (you're taken to the next page, data is entered in the DB), when you hit "next" on page 2 I get the following error:

Error in query: UPDATE client SET service='service1' WHERE ID=. You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Any help would be greatly appreciated... let me know if you would like to see code or anything to help me out!

06-19-2006, 02:13 AM
How are you grabbing the ID? Are you starting the session on both pages?

06-19-2006, 02:20 AM
I have the session_start(); on page 2 and on page 3 of the registration page... Not on page 1... Is that allright? I don't think I need it for page 1

06-19-2006, 02:54 AM
You do if you're working with session variables.

06-19-2006, 03:01 AM
oh I see.. So I have to start the session on page one even though there is an INSERT rather than UPDATE?

I thought that only the UPDATE had to call the session to pick up the ID??

Care to explain?


06-19-2006, 03:03 AM
It worked!!

Thanks... I'd still appreciate an explanation if you can!

06-20-2006, 02:08 AM
If you don't start the session on page 1, you cannot set a session variable on that page to pass along to pages 2 and 3. It has nothing to do with what kind of sql query you are working with.

06-20-2006, 02:37 AM
From the PHP manual

session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie.

In order to access session data in the page you need to call the session_start() function. And session_start() must be called before anything is outputted to the browser.