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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post

    Database issue on new laptop

    Hey, I have enabled everything in IIS on a Windows 8 laptop and tried to run some code, this code works fine on my Windows 7 laptop. But for some reason with this laptop im getting the following error

    Code:
     No value given for one or more required parameters.
    Here is my ASP code
    Code:
    <!--#include virtual="\nightclub_photography\asp\md5.asp"-->
    
    <%
    on error resume next
    
    'Retreive the URL variables'
    email = Trim(request.querystring("email"))
    password = request.querystring("password")
    
    'Check the data has been entered into the fields'
    if email = "" then
        response.write "Error: Please enter your email!"
        response.End
    End If
    If password = "" then
        response.write "Error: Please enter a password!"
        response.End
    End If
    
    'Create connection and load users database
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.ACE.OLEDB.12.0"
    conn.Open Server.MapPath("/nightclub_photography/data/database/jamsnaps.mdb")
    
    'Query for searching users by email
    query = "select * from users WHERE email = '" & email & "' AND password = '" & md5(password) & "'"
    
    set rs=conn.Execute(query)
    
    If Err.Number <> 0 Then
      Response.Write ("Error: " & Err.Description& "<br><br>")
    End If	
    
    'Check if the username matchs in the database
    if rs.EOF then
    	response.write("Error: Login details incorrect!")
    	conn.close
    else
    		'Fetch, and capitlize name
    		full_name = ucase(mid(rs.Fields("fname"),1,1))&mid(rs.Fields("fname"),2)&" "
    		full_name = full_name + ucase(mid(rs.Fields("sname"),1,1))&mid(rs.Fields("sname"),2)
    		
    		'Set session variables
    		Response.Cookies("perms") = rs.Fields("perms")
    		Response.Cookies("uid")("fullname") = full_name
    		Response.Cookies("uid")("email") = rs.Fields("email")
    		Response.Cookies("uid")("id") = rs.Fields("id")
    		Response.Cookies("sdate") = FormatDateTime(Now, 2)
    		Response.Cookies("sc") = 0587362781
    		
    		'Expire in 2 days to be safe
    		Response.Cookies("perms").Expires = Date() + 2
    		Response.Cookies("uid").Expires = Date() + 2
    		Response.Cookies("sdate").Expires = Date() + 2
    		Response.Cookies("sc").Expires = Date() + 2
    		
    		'Write message and create cookies for session
    		response.write("Message: Login Successful!")
    		conn.close
    end if
    %>
    Any ideas, I dont know if I missed a certain setting that I may have changed with my Windows 7 laptop .
    Last edited by martynball; 09-23-2013 at 10:16 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,496 Times in 4,460 Posts
    And what LINE is that error on??

    And where is your DEBUG DEBUG DEBUG code??

    And this code is pointless
    Code:
    If Err.Number <> 0 Then
      Response.Write ("Error: " & Err.Description& "<br><br>")
    End If
    unless you are also using ON ERROR RESUME NEXT.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    martynball (09-29-2013)

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    And what LINE is that error on??

    And where is your DEBUG DEBUG DEBUG code??

    And this code is pointless
    Code:
    If Err.Number <> 0 Then
      Response.Write ("Error: " & Err.Description& "<br><br>")
    End If
    unless you are also using ON ERROR RESUME NEXT.
    I believe the error is the conn.execute(). And I have the on error resume next at the start of the ASP code.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,496 Times in 4,460 Posts
    Quote Originally Posted by martynball View Post
    I believe the error is the conn.execute(). And I have the on error resume next at the start of the ASP code.
    Why would you say you BELIEVE that but then not bother to find out FOR SURE? Do you not believe in debugging???

    I would replace this:
    Code:
    query = "select * from users WHERE email = '" & email & "' AND password = '" & md5(password) & "'"
    with something like:
    Code:
    Err.Clear 
    
    md5pw = md5(password)
    
    Response.Write "md5pw is " & md5pw & ", err.Number is " & err.Number & "<hr/>"
    
    query = "select * from users WHERE email = '" & email & "' AND password = '" & md5pw & "'"
    
    Response.Write "query: " & query & "<hr/>"
    
    Response.Write "before execute, err.Number is " & err.Number & "<hr/>"
    
    conn.Execute( query )
    
    Response.Write "after execute, err.Number is " & err.Number & ", description: " & err.Description & "<hr/>"
    Until and unless you learn to use debug code, you will likely never figure out your own problems.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    martynball (09-29-2013)

  • #5
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Here is the result of the code you gave me. And I had narrowed the error down to being the conn.Execute as I put the If Err.Number <> 0 Then above the conn.Execute and then a line below and an error only occured when it was below.

    Your way is much better though I'm still getting used to ASP, I prefer to code in PHP.

    Code:
    md5pw is af453d19feb2520c8c0d30fb39ebd211, err.Number is 0
    query: select * from users WHERE email = 'martynleeball@gmail.com' AND password = 'af453d19feb2520c8c0d30fb39ebd211'
    before execute, err.Number is 0
    after execute, err.Number is -2147217904, description: No value given for one or more required parameters.
    Error: Login details incorrect!

  • #6
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Hmm, I used Execute as I should only be getting 1 result from the database so I thought this would be the best way to go.

    I have just changed the code the following instead, and it works. Although I also removed AND password = '" & md5pw &'" from the query and the error stopped occuring. Don't understand what was causing it, but it now works.

    PHP Code:
        <!--#include virtual="\nightclub_photography\asp\md5.asp"-->

        
    <%
        
    on error resume next

        
    'Retreive the URL variables'
        
    email Trim(request.querystring("email"))
        
    password request.querystring("password")

        
    'Check the data has been entered into the fields'
        
    if email "" then
            response
    .write "Error: Please enter your email!"
            
    response.End
        End 
    If
        If 
    password "" then
            response
    .write "Error: Please enter a password!"
            
    response.End
        End 
    If

        
    'Create connection and load users database
        set conn=Server.CreateObject("ADODB.Connection")
        conn.Provider="Microsoft.ACE.OLEDB.12.0"
        conn.Open Server.MapPath("/nightclub_photography/data/database/jamsnaps.mdb")
        
        '
    Create record set
        Set rs 
    Server.CreateObject("ADODB.recordset")

        
    Err.Clear

        md5pw 
    md5(password)

        
    query "select * from users WHERE email = '" email "'"

        
    rs.Open queryconn

        
    'Check if the username matchs in the database
        if rs.EOF  = false then
            if rs.fields("password") = md5pw then
                '
    Fetch, and capitlize name
                full_name 
    ucase(mid(rs.Fields("fname"),1,1))&mid(rs.Fields("fname"),2)&" "
                
    full_name full_name ucase(mid(rs.Fields("sname"),1,1))&mid(rs.Fields("sname"),2)
                
                
    'Set session variables
                Response.Cookies("perms") = rs.Fields("perms")
                Response.Cookies("uid")("fullname") = full_name
                Response.Cookies("uid")("email") = rs.Fields("email")
                Response.Cookies("uid")("id") = rs.Fields("id")
                Response.Cookies("sdate") = FormatDateTime(Now, 2)
                Response.Cookies("sc") = 0587362781
                
                '
    Expire in 2 days to be safe
                Response
    .Cookies("perms").Expires Date() + 2
                Response
    .Cookies("uid").Expires Date() + 2
                Response
    .Cookies("sdate").Expires Date() + 2
                Response
    .Cookies("sc").Expires Date() + 2
                
                Write message 
    and create cookies for session
                response
    .write("Message: Login Successful!")
            
    end if
            
    conn.close
        end 
    if
        %> 

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,496 Times in 4,460 Posts
    Only thing I can think of is that maybe password is a keyword in the Microsoft.ACE.OLEDB.12.0 driver that you are using.

    If so, you should be able to get it to work by putting [...] around the word password.

    That is:
    Code:
    select * from users 
    WHERE email = 'martynleeball@gmail.com' 
    AND [password] = 'af453d19feb2520c8c0d30fb39ebd211'
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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