Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    240
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How are you grabbing the ID? Are you starting the session on both pages?

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    240
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Jan 2006
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You do if you're working with session variables.
    ___________________________________
    Bach and Bradley Internet Media
    Professional, customized web solutions, specializing in PHP and XHTML

  • #5
    Regular Coder
    Join Date
    Mar 2005
    Posts
    240
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #6
    Regular Coder
    Join Date
    Mar 2005
    Posts
    240
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It worked!!

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

  • #7
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •