Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

only display image if filename in database

Explorer ,
Jul 09, 2006 Jul 09, 2006
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.
TOPICS
Server side applications
396
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2006 Jul 10, 2006
You are already in a server code block when you try and call the <%=bookImage%> this is why it fails. Change that line to this...

Response.Write("<img src='i/bookCovers/" & bookImage & "'/>")
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 13, 2006 Jul 13, 2006
Thanks for your repsonse, that worked perfectly.

I'm now in trouble with the same thing, I can't figure out what"s what !:

<%
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&oacute;n espa&ntilde;ola &raquo;</A>")
else
End If
%>

I've tried to put the double quotes in the right places, but can't get it right. Any help much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 14, 2006 Jul 14, 2006
LATEST
LOL, I know you read my original reply but did you actually take it in? You're making the same mistake in this new bit of code as you were making in the first one.

Apply the same principle, take out the server tags as you are already coding IN a script block.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines