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 4 of 4

Thread: admin script

  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    admin script

    i have a basic admin script that allows you to add, delete and update user. I have an error with the add script:

    <%

    Set conn = server.createobject("adodb.connection")
    DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("netteh.mdb")
    conn.Open DSNtemp

    'here we are determining which form its from and getting the info from the form
    'the first two represent the user form
    'we will use this to add to the database
    If Request.Form("T1") > "" Then
    Username= Request.Form("T1")
    Password = Request.Form("T2")
    Else
    Username = Request.Form("T3")
    Password= Request.Form("T4")
    End If

    If Request.Form("T1") > "" Then
    SQL = "Insert INTO Students(Username,Password) Values ('" & Username & "','" & Password& "')"
    Else
    SQL = "Insert INTO admin (Username,Password) Values ('" & Username & "','" & Password & "')"
    End If
    Conn.Execute(SQL)
    Conn.Close
    Response.Redirect "admin2.asp"
    %>

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error in INSERT INTO statement.
    /TMP7jgep38a0v.asp, line 23


    Line 23:
    If Request.Form("T1") > "" Then
    SQL = "Insert INTO Students(Username,Password) Values ('" & Username & "','" & Password& "')"
    Else
    SQL = "Insert INTO admin (Username,Password) Values ('" & Username & "','" & Password & "')"
    End If

    Do you guys have a better admin script? i would like one that has user levels and be able to delete, add and updat users. thanks in advance

  • #2
    New Coder
    Join Date
    Aug 2004
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't have an admin script, but you could use the SQL statement editor in Access to work out the kinks in your SQL statement. Once you get it to work with live data, transfer it over to you code and replace the values with your variables and 'codify' it.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Username and/or Password are reserved words in Access. Try renaming them.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree with Glenn... specifically, password is DEFINITELY a reserved word in Access (I know this from previous experience).

    If you're using SQL Server you can get around that by using brackets [] around the offending field name.

    If you're using access, you might just want to use "pass" instead of password. I don't think "username" is a reserved word (I could be wrong!), but it's a good practice to not use really common computer names for database fields. They *should* be descriptive, however!
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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