Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 20th, 2008, 01:51 PM
Authorized User
 
Join Date: Apr 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default using an IF statement with a recordset field

Hello super programmers! Once again I seek your help....

I want to use .asp classic to create an if statement for my graphics....

I have a MySQL database running. I have a field called "masthead". This field holds the name of my images. I need an if stement to check if a name exists. if not, then use the hardcoded image. see my code as what I am trying to achieve... This page gets called in by a simple query string from a hyperlink.

<%
  masthead = Rs("masthead")

  If masthead ="" then %>

        <img src='product_images/masthead_homepage.jpg' border="0">
            <% else%>
<img src='product_images/<%=Rs("masthead")%>' width="760" height="63" border="0">
<% end if %>

any ideas??? It just doesnt work.

 
Old March 20th, 2008, 02:09 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

How doesnt it work?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 20th, 2008, 02:12 PM
Authorized User
 
Join Date: Apr 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is displaying the image that is outside of the else statement, in which the image would be missing because I have a blank field in the database.

It seems the "if" statement is being ignored.... do I have the if statement correct?

 
Old March 20th, 2008, 03:04 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

My guess is that masthead doesn't really equal an empty string like you are expecting, have you tried using Trim(masthead)?

Edit:
What I mean is:

If Trim(masthead) = "" Then
'Do Something
Else
'Do Something else
End If
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable used in recordset field name the4barkersab Access VBA 1 February 24th, 2008 04:18 PM
bind recordset to field ibgreen SQL Language 0 October 24th, 2006 12:48 PM
Hard (recordset field) reading fskilnik Dreamweaver (all versions) 10 November 28th, 2005 06:05 PM
Retrieve recordset field value tryntolearn Classic ASP Databases 1 August 8th, 2005 10:22 AM
Variable Recordset Field Name Codesucks VB Databases Basics 6 June 1st, 2004 07:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.