Results 1 to 10 of 10

Thread: I can't hyperlink this image

  1. #1
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question I can't hyperlink this image

    Hi Every body ,
    I'm selecting this image from my sql server DB, and it is displayed correctly.But when I try ti add a hyperlink to it it gives this error.

    Error Type:
    Response object, ASP 0106 (0x80020005)
    An unhandled data type was encountered.
    /web/login.asp, line 233

    This is my query
    Code:
    <%
    	sql="select * from advertisment where adv_place=2 "
    	set rs=conn.Execute (sql)
    	if not rs.eof then
    	%>
    	<a href="<%=rs("href")%>">
    	<%Response.ContentType = "image/gif"%>
    	<img src="<% Response.BinaryWrite rs("adv_image")%>"></a>
    	<%else%>
    	<img src="pic/sad-smol.jpg">
    	<%end if%>
    thank u all,
    Yoya

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What sort of SQL server are you running?
    What is the contents of this field ("href")?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm using sql server 2000 and the href have the path of the page i wan't to dispaly . and yhe image is stored in the DB Not only its path

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Aha, I see. You cannot embed the image inside HTML, which is what you seem to be trying to do. You must create a new page, then use that as the src for the image.
    Also, you cannot change the Content-Type after data has already been sent.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Thank u ,
    But I tried something and it worked. I had to repeat the SQL statement once more like this :

    Code:
    <%
    	sql="select * from advertisment where adv_place=2 "
    	set rs=conn.Execute (sql)
    	if not rs.eof then
    	%>
    	<a href="<%=rs("href")%>">
    	<%
    	sql="select * from advertisment where adv_place=2 "
    	set rs=conn.Execute (sql)
    	%>
    	<%
    	if not rs.eof then
    	Response.ContentType = "image/*"
    	%>
    	<img src="<%Response.BinaryWrite rs("adv_image")%>">
    	<%else%>
    	<img src="pic/sad-smol.jpg">
    	<%end if
    	%>
    and like this it showed the image and hyperlinked it >
    But there is still aproblem the path of the link is in the local host this way
    http://localhost/www.yahoo.com
    which is wrong path so my question is , will it change once it published or will it stay the same ?
    And if it will stay the same what can i do for changing it ?
    Thanks again
    Yoya

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It works?! Then I must be misunderstanding you, since the logic of that script would appear to be messed up beyond all possibility of working.

    adv_image contains the binary data of the image, does it not?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes it contains the binary data, your not the first to tell me this code is messed up . but it realy worked . so my only concern now is this link will dispaly correctly or will it stay in the local host. the href field containse "www.yahoo.com" but when i run it the address goes "http://localhost/www.yahoo.com " will it change when it published
    thanx

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Add http:// onto the beginning.
    Well, I'd be very interested to see the output of this script, if you could send a link...?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    it is not published yet , i'll send it to you once it's published
    Thank any way ,it's a pleasure to be in this forum

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Thank you.
    Mike, what do you make of this?

    (Mike being our resident Expert on Everything )
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •