Forums

ASP

This topic is locked

only display image if filename in database

Posted 10 Jul 2006 09:47:17
1
has voted
10 Jul 2006 09:47:17 richard thomas posted:
Hi,
I'm trying to write the code to only display an image if there is a file name in the database for the image (i.e. if there is no image for the item, no image tags are written to the page etc)

Heres what I have:

<code>

<%
Dim bookImage
bookImage = (rsBooks.Fields.Item("book_imageURL".Value)
If bookImage > 1 then
Response.Write("<img src='i/bookCovers/<%=bookImage%>'/>"
Else
End If

%>

</code>

I'm getting the following error:

Unterminated string constant

/index.asp, line 197

Response.Write("<img src='i/bookCovers/<%=bookImage
---------------------------------------------------^

I can't figure the problem.

Appreciate any advice.

Replies

Replied 10 Jul 2006 23:34:45
10 Jul 2006 23:34:45 micah santos replied:
<%

Dim bookImage

bookImage = (rsBooks.Fields.Item("book_imageURL".value)

if LEN(trim(bookImage)) > 1 Then
response.Write("<img src='i/bookCovers/<%=bookImage%>'/>"
%>
Replied 11 Jul 2006 17:07:02
11 Jul 2006 17:07:02 Wayne Hultum replied:
If bookImage <>"" then
Replied 13 Jul 2006 16:23:10
13 Jul 2006 16:23:10 richard thomas replied:
Thanks guys, I found the following now works a treat:

<%
Dim bookImage
bookImage = (rsBooks.Fields.Item("book_imageURL".Value)
If bookImage > "" then
Response.Write("<img src='i/bookCovers/"+bookImage+"' alt=""Cover Image"" width=""54"" height=""81"" />"
else
End If
%>

However I have a similare problem mixing my modes. Can anyone help with this one:

<%
Dim spanishReview
spanishReview = (rsBooks.Fields.Item("book_spanish_title".Value)
If spanishReview > "" then
Response.Write("<A HREF='ReviewSpanish.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & ""book_id="" & rsBooks.Fields.Item("& book_id & ".Value%>'>Revisión española »</A>"
else
End If
%>

The error I get is:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/index.asp, line 194

Response.Write("<A HREF='ReviewSpanish.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & ""book_id="" & rsBooks.Fields.Item("& book_id & ".Value

Thank anyone, I don't get the mixed mode thing...

Reply to this topic