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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vbscript string comparison problem

  • 22-09-2008 3:08pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 21,263 ✭✭✭✭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