PDA

View Full Version : I can't hyperlink this image



yoyali
05-16-2006, 07:29 AM
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

<%
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

Twey
05-16-2006, 08:17 AM
What sort of SQL server are you running?
What is the contents of this field ("href")?

yoyali
05-16-2006, 12:49 PM
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

Twey
05-16-2006, 12:54 PM
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.

yoyali
05-16-2006, 01:12 PM
Thank u ,
But I tried something and it worked. I had to repeat the SQL statement once more like this :


<%
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

Twey
05-16-2006, 01:33 PM
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?

yoyali
05-16-2006, 02:16 PM
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

Twey
05-16-2006, 02:21 PM
Add http:// onto the beginning.
Well, I'd be very interested to see the output of this script, if you could send a link...?

yoyali
05-16-2006, 02:24 PM
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

Twey
05-16-2006, 02:26 PM
Thank you.
Mike, what do you make of this?

(Mike being our resident Expert on Everything :p)