+ Post New Thread
Results 1 to 4 of 4
Web Development Thread, MySQL overwriting entries in database in Coding and Web Development; Im having some trouble with a MySQL database that I've been using with an online application form i developed a ...
  1. #1

    Join Date
    Jan 2013
    Posts
    11
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Exclamation MySQL overwriting entries in database

    Im having some trouble with a MySQL database that I've been using with an online application form i developed a few weeks back. I thought I had finished the form as i didn't have any errors until we have come to test it over the past few days. The problem is When 2 different users use the form, or the same user closes the browser and starts a new session, the newest data will overwrite all other data in each field across all tables. Also if one person is filling out the form and a second users then starts a few moments after, the first person is then referred to the beginning when they move forward a page as the data base has lost all previous information.

    you can see the form at www.moorpark.lancs.sch.uk/teachapp/

    the pages go as follows with each step page running an included 'process' page

    default.asp

    step-2.asp
    -process-1.asp

    step-3.asp
    -process-2.asp

    step-4.asp
    -process-3.asp

    step-final.asp
    -process-4.asp

    if needed i can sort out some paste bins of the full page code.


    Thanks!


    I have just noticed i have missed a 'where' statment off the end of my sql syntax.
    Last edited by cooper549; 1st May 2013 at 11:34 AM. Reason: Think i might have solved it :)

  2. #2
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    888
    Thank Post
    84
    Thanked 234 Times in 193 Posts
    Rep Power
    82
    Pastes of the SQL statements that update / insert into the database would be essential here. Essentially sounds like you're using an UPDATE when you should be using an INSERT INTO basically... and some of your javascript functionality (eg: onfocus within the "title" input) is incorrect.
    Last edited by Marci; 1st May 2013 at 11:39 AM.

  3. #3

    Join Date
    Jan 2013
    Posts
    11
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hes a snippet from the process-1.asp.

    It inserts fine when nothing else was present the problem came to when it was updating, of which i think i have fixed now.

    Code:
        SQLch = "SELECT UsersRef FROM teachapp WHERE UsersRef = '" & UsersRef & "'"    Set RSch = Conn.execute(SQLch)
    
    
        if RSch.EOF then
    
    
            SQLa = "INSERT into teachapp (appsDate, Us......(CUT OUT CODE TO SAVE SPACE).....','"& sONEotherpostcode &"','"& sONEothertel &"');"
            Conn.execute (SQLa)
            SQLa = "INSERT into teachapp2 (UsersRef) VALUES ('"&UsersRef&"');"
            Conn.execute (SQLa)
            SQLa = "INSERT into teachapp3 (UsersRef) VALUES ('"&UsersRef&"');"
            Conn.execute (SQLa)
            SQLa = "INSERT into teachapp4 (UsersRef) VALUES ('"&UsersRef&"');"
            Conn.execute (SQLa)
            SQLa = "INSERT into teachapp5 (UsersRef) VALUES ('"&UsersRef&"');"
            Conn.execute (SQLa)
        
        else
    
    
            SQLu = "update teachapp set appsDate='"&appsDate&"',UsersRef='"&Us............(CUT OUT CODE TO SAVE SPACE)..................stcode&"',sONEothertel='"&sONEothertel&"'"
            Conn.execute (SQLu)
            SQLu = "update teachapp2 set UsersRef='"&UsersRef&"'"
            Conn.execute (SQLu)
            SQLu = "update teachapp3 set UsersRef='"&UsersRef&"'"
            Conn.execute (SQLu)
            SQLu = "update teachapp4 set UsersRef='"&UsersRef&"'"
            Conn.execute (SQLu)
            SQLu = "update teachapp5 set UsersRef='"&UsersRef&"'"
            Conn.execute (SQLu)
    
    
        end if
         end if
    That was my original however ive noticed that at the end of my updates i missed
    Code:
    where UsersRef='"&UsersRef&"'"

  4. #4
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    888
    Thank Post
    84
    Thanked 234 Times in 193 Posts
    Rep Power
    82
    That would do it, yep.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 6
    Last Post: 28th February 2012, 12:33 PM
  2. [SIMS] Duplicate Entries in Lookups
    By Stuart_C in forum MIS Systems
    Replies: 2
    Last Post: 3rd May 2011, 11:01 AM
  3. CREATOR OWNER entry in NTFS Security
    By Ignatius in forum Windows
    Replies: 7
    Last Post: 22nd September 2010, 10:09 PM
  4. Replies: 0
    Last Post: 24th March 2010, 09:51 AM
  5. "PHP Warning: Module 'mysql' already loaded in Unknown on line"
    By MattGibson in forum Windows Server 2000/2003
    Replies: 0
    Last Post: 18th November 2009, 08:39 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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