Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

vbscript string comparison problem

Options
  • 22-09-2008 4:08pm
    #1
    Registered Users Posts: 872 ✭✭✭


    Hi,

    I have to update an old website that used vbscript.

    I need to check if a field is a certain email address and then write out some text.
    <%if(Trim(RS("contact"))="me@email.com") then Response.Write("Email Me") end if %>
    

    The value RS("contact") comes from an access db, is a memo data type and definetly has the value 'me@email.com'

    When i try and run the condition above it doesnt write out "Email Me" so the if condition isnt matching the value in the column.

    Am i making a simple mistake here ?

    Thanks in advance


Comments

  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Are memo fields not for much bigger text fields? I presume you can print out the variable OK?

    Try this:

    If cStr(Trim(RS("contact"))) ="me@email.com" Then
    ...
    End If


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Quick question - Is this a vbscript on a HTML page or is it part of an ASP page - you're saying vbscript but I'm assuming this is actually an ASP page otherwise the variable will not be set so that the vbscript can interrogate it. Have you tried outputting the value of the variable and seeing what's being sent to it? You're pulling down from a database though so this may not be feasible (I'm assuming there is more than one record in the db). What is the purpose of this script - there may be an easier way to achieve the result you are looking for. If this is an ASP page could you please post all of the file in case the variable is being emptied earlier in the code. If it's not an ASP page then there is no way to pass the variable to the script. Hope that's some help.

    I've just noticed the <% brackets so definitely some sort of script. Fine, that means there is some problem accessing the variable in that case. Can you please supply a larger code snippet (ideally all the code prior to the statement causing you trouble)?


Advertisement