Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-19-2006, 12:37 AM   PM User | #1
losse
Regular Coder

 
Join Date: Mar 2005
Posts: 240
Thanks: 1
Thanked 0 Times in 0 Posts
losse is an unknown quantity at this point
Struggling with an error!

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:

Code:
 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!
losse is offline   Reply With Quote
Old 06-19-2006, 01:13 AM   PM User | #2
cubsfan
Regular Coder

 
Join Date: May 2006
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
cubsfan is an unknown quantity at this point
How are you grabbing the ID? Are you starting the session on both pages?
cubsfan is offline   Reply With Quote
Old 06-19-2006, 01:20 AM   PM User | #3
losse
Regular Coder

 
Join Date: Mar 2005
Posts: 240
Thanks: 1
Thanked 0 Times in 0 Posts
losse is an unknown quantity at this point
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
losse is offline   Reply With Quote
Old 06-19-2006, 01:54 AM   PM User | #4
Jesters8
New Coder

 
Join Date: Jan 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Jesters8 is an unknown quantity at this point
You do if you're working with session variables.
__________________
___________________________________
Bach and Bradley Internet Media
Professional, customized web solutions, specializing in PHP and XHTML
Jesters8 is offline   Reply With Quote
Old 06-19-2006, 02:01 AM   PM User | #5
losse
Regular Coder

 
Join Date: Mar 2005
Posts: 240
Thanks: 1
Thanked 0 Times in 0 Posts
losse is an unknown quantity at this point
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?

Thanks
losse is offline   Reply With Quote
Old 06-19-2006, 02:03 AM   PM User | #6
losse
Regular Coder

 
Join Date: Mar 2005
Posts: 240
Thanks: 1
Thanked 0 Times in 0 Posts
losse is an unknown quantity at this point
It worked!!

Thanks... I'd still appreciate an explanation if you can!
losse is offline   Reply With Quote
Old 06-20-2006, 01:08 AM   PM User | #7
cubsfan
Regular Coder

 
Join Date: May 2006
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
cubsfan is an unknown quantity at this point
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.
cubsfan is offline   Reply With Quote
Old 06-20-2006, 01:37 AM   PM User | #8
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,225
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
From the PHP manual

Quote:
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.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:52 AM.


Advertisement
Log in to turn off these ads.