Click to See Complete Forum and Search --> : Help with banner ad...


malhyp
01-22-2007, 11:59 PM
Hey there... Can one help me with the follwong code?

The banner ad i have installed seems to work almost fine. When you click onto the pic (banner ad) it takes me to the address below instead of the one intended.

<%
Response.Buffer=True

'Define our ADO constants
const adOpenStatic = 3
const adLockOptimistic = 3

'----- Create and Open Connection
Set MyConnection = Server.CreateObject("ADODB.Connection")
MyConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\blablabla"
MyConnection.Open

'----- Pick Ad from database
SQLBanner = "Select * from Banner"
Set Banners = Server.CreateObject("ADODB.Recordset")
Banner.CursorType = adOpenStatic
BannersLockType = adLockOptimistic
Banner.Open SQLBanners, MyConnection

Randomize Timer
Banner.Move Int(RND * CInt(Banner.RecordCount))

'----- Increment Shown field value
Banner("Shown") = Banner("Shown") + 1
Banner.Update

' <a href="RedirectMe.asp?URL="www.google.com&BannerID="1"" "target="blank">image</a>

'----- Create and display Response
ImageString = "<img src=""" & Banner("Image") & """ alt=""" & Banner("Hint") & """>"
'ImageString = "<a href=""" & Banner("Image") & """ target=""_blank""><img src=""" & Banner("Image") & """ alt=""" & Banner("Hint") & """></a>"
ResponseString = "<a href=""RedirectMe.asp?URL=" & Banner("URL")
ResponseString = ResponseString & "&BannerID=" & Banner("BannerID") & """" & " " & "target=""_blank""" & ">" & ImageString & "</a>"
Response.Write ResponseString
'Response.End

'----- Clean up memory
Banner.Close
MyConnection.Close
Set Banner=Nothing
Set MyConnection=Nothing
%>

---------------------------------------------------------
Takes me here...
http://www.example.com/html/products/RedirectMe.asp?URL=www.test.com&BannerID=1

But need it to go here...
www.test.com

Can anyone tell me what I am doing wrong?

Mally

nbcrockett
01-23-2007, 07:20 AM
Looks like it can't find RedirectMe.asp. It's pulling the value from the database though. Is RedirectMe.asp in the /html/products/ folder?

malhyp
01-24-2007, 03:36 AM
No I cant find one anywere.

nbcrockett
01-24-2007, 07:27 AM
Right now your string is set up to pass the Banner("URL") and Banner("ID") values to a page called RedirectMe.asp. We obviously can't tell what those values are for since you don't have the page, so I would suggest that you change this part of your code:

ResponseString = "<a href=""RedirectMe.asp?URL=" & Banner("URL")
ResponseString = ResponseString & "&BannerID=" & Banner("BannerID") & """" & " " & "target=""_blank""" & ">" & ImageString & "</a>"

to this:

ResponseString = "<a href='" & Banner("URL") & "' target='_blank'>" & ImageString & "</a>"

malhyp
01-24-2007, 03:55 PM
The count wont work with that but at least the url now works.

Thanks for your help

Cheers

nbcrockett
01-25-2007, 07:04 AM
What count are you referring to?