Computer Hope

Software => Computer programming => Topic started by: High1 on May 31, 2014, 01:03:56 PM

Title: Classic ASP: error '800a000d' Type mismatch
Post by: High1 on May 31, 2014, 01:03:56 PM
Hello

I have a simple log-in form with four fields and the server gives me the following error:

Quote
Microsoft VBScript runtime  error '800a000d'

Type mismatch: '[string: "maria"]'

/schoolsReg/Login.asp, line 23

'maria' refers to my chosen password.

Line 23 is this: if username = "" or password or fullname or strEmail = "" then

strEmail corresponds to the email column in my MS Access 2003 database.

The rest of my code looks like this:

Code: [Select]
<%
username = ""
 password = ""
ErrorMessage = ""
strEmail = ""
fullname = ""

if request.form <> "" then
   username = Request.Form("username")
  password = Request.Form("password")
 fullname = Request.Form("fullname")
 strEmail = Request.Form("strEmail")

  if username = "" or password or fullname or strEmail = "" then [color=red]<---- where the error occurs[/color]

    ErrorMessage = "You must specify a username, password, your full name and email address."
  else
     set conn = Server.CreateObject("ADODB.Connection")

conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    conn.Open("E:\myDatabase.mdb")
   
    set rs = Server.CreateObject("ADODB.recordset")   
   
 rs.Open "Select * FROM Users WHERE strEmail = '" & username & "'" & fullname & "'", conn

if rs.EOF = false then
      if rs.fields("password") = password then
         Response.Redirect("Default.asp")
      end if
    end if
  ErrorMessage = "Login failed"
  end if
end if

if ErrorMessage <> "" then
   response.write("<p>" & ErrorMessage & "</p>")
   response.write("<p>Please correct the errors and try again.</p>")
 end if
%>

<h1>Login</h1>
<form method="post" action="">
<fieldset>
 <legend>Log In to Your Account</legend>
<ol>
<li>
 <label>Username:</label>
<input type="text" id="username" name="username" />
</li>
<li>
<label>Password:</label>
 <input type="password" id="password" name="password" />
</li>

<li>
 <label>Full name:</label>
<input type="text" id="fullname" name="fullname" />
</li>

<li>
 <label>Email:</label>
<input type="text" id="strEmail" name="strEmail" />
</li>

<li>
 <p><input type="submit" value="Login" /></p>
</li>
</ol>
 </fieldset>
</form>

</div>
 </body>
</html>

What am I doing wrong, please?

High1
Title: Re: Classic ASP: error '800a000d' Type mismatch
Post by: BC_Programmer on May 31, 2014, 01:53:33 PM
Quote
Code: [Select]
if username = "" or password or fullname or strEmail = "" then

Or cannot be used on two strings. You are missing ="" comparisons for password and fullname.
Title: Re: Classic ASP: error '800a000d' Type mismatch
Post by: High1 on May 31, 2014, 03:04:20 PM
Hello mastermind

Many thanks for your reply.

So I would have to use if username = "" or password = "" then only?

How would I include 'fullname' and 'strEmail', if I may ask?

Thank you

High1
Title: Re: Classic ASP: error '800a000d' Type mismatch
Post by: High1 on May 31, 2014, 06:49:38 PM
I'll try using this (and abandon fullname as it's not really essential):

if username = "" or password = "" or strEmail = "" then

High1