Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Banner ad rotate app, errors, and problems....

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
First time creating a banner ad rotate system, nothing to fancy but it seems to be causing problems and havn't found them. For one its not rotating, which maybe because of the way I did it, if there is a better way let me know...


<-view error here
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: &quot;&quot;]'

/ad/Default.asp, line 84

Code:
<% If Request.QueryString(&quot;action&quot;) <> &quot;click&quot; then 
	
	Dim ConnString
	Dim sqlSelectBanner, sqlSelectBannerID   '# SQL statements
	Dim strBannerIds, strBannerIdSplit		   '# Store all banner ids in db,  Split all banner ids
	Dim RandomBannerID, strPickedID
	Dim strViewed
			
		ConnString = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;banner.mdb&quot;)

	
		Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
		conn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;banner.mdb&quot;) & &quot;;&quot;
		Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
		
		sqlSelectBanner = &quot;SELECT * FROM banners&quot;

		rs.Open sqlSelectBanner, conn, 1, 1 


	Do while not rs.eof  
		strBannerIds = strBannerIds & &quot;|&quot; & rs(&quot;bID&quot;) '#Get all banner ids in db
	rs.movenext
	loop
		strBannerIds = strBannerIds & &quot;|&quot; & &quot;linkex&quot;   '# Add link exchange to all banner id list
	
	
	strBannerIdSplit = Split(strBannerIds, &quot;|&quot;)			'# Split banner id's at the verticle pipe (|)
	
	RandomBannerID = int(rnd*ubound(strBannerIdSplit))  
	
	strPickedID = strBannerIdSplit(RandomBannerID)
	
	Response.Write &quot;All banner Ids= &quot; & strBannerIds & &quot;~&quot; & &quot; Picked ID= &quot; & strPickedID

	'##############################################
	'# Get banner info, display banner..
	
	If strBannerIdSplit(RandomBannerID) = &quot;linkex&quot; then
		Response.Write &quot;<!-- BEGIN LINKEXCHANGE CODE -->&quot;
		Response.Write &quot;<center>&quot;
		Response.Write &quot;<iframe src=&quot;&quot;[URL unfurl="true"]http://leader.linkexchange.com/X1658898/showiframe?&quot;&quot;[/URL] width=468 height=60 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no> &quot;
		Response.Write &quot;<a href=&quot;&quot;[URL unfurl="true"]http://leader.linkexchange.com/X1658898/clickle&quot;&quot;[/URL] target=&quot;&quot;_top&quot;&quot;><img width=468 height=60 border=0 ismap alt=&quot;&quot;&quot;&quot; src=&quot;&quot;[URL unfurl="true"]http://leader.linkexchange.com/X1658898/showle?&quot;&quot;></a></iframe><br>&quot;[/URL]
		Response.Write &quot;</center>&quot;
		Response.Write &quot;</td>&quot;
		Response.Write &quot;</tr>&quot;
		Response.Write &quot;<tr>&quot;
		Response.Write &quot;<td bgcolor=&quot;&quot;#999999&quot;&quot;> &quot;
		Response.Write &quot;<center>&quot;
		Response.Write &quot;<a href=&quot;&quot;[URL unfurl="true"]http://leader.linkexchange.com/X1658898/clicklogo&quot;&quot;[/URL] target=&quot;&quot;_top&quot;&quot;><img src=&quot;&quot;[URL unfurl="true"]http://leader.linkexchange.com/X1658898/showlogo?&quot;&quot;[/URL] width=468 height=16 border=0 ismap alt=&quot;&quot;&quot;&quot;></a><br>&quot;
		Response.Write &quot;</center>&quot;
		Response.Write &quot;<!-- END LINKEXCHANGE CODE -->&quot; 
		
		Response.End
	End If
	
	set my_conn = nothing
	set rs = nothing
	
	set my_conn= Server.CreateObject(&quot;ADODB.Connection&quot;)
	set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

	my_conn.Open ConnString

	sqlSelectBannerID = &quot;SELECT * FROM banners WHERE bID=&quot; & strPickedID
	rs = my_conn.Execute(sqlSelectBannerID)
	
	strViewed = rs(&quot;b_shown&quot;)
	
%>
<div align=&quot;center&quot;><a href=&quot;[URL unfurl="true"]http://www.vzio.com/ad?action=click&ref=<%=Request.ServerVariables(&quot;HTTP_REFERER&quot;)%>&banner=<%=strPickedID%>&quot;><img[/URL] src=&quot;<%=rs(&quot;b_img&quot;)%>&quot; border=&quot;0&quot;></a></div>
<%
my_conn.Close
set my_conn = nothing
set rs = nothing

'############## Update viewed times#######################

	set my_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
	my_conn.Open ConnString

	
	mySQL = &quot;UPDATE banners SET &quot; _
		& &quot;b_shown = '&quot; & strViewed + 1 & &quot;'  &quot; _
		& &quot;WHERE bID =&quot; & strPickedID

	rs = my_conn.Execute(mySQL)

	my_conn.Close
	set my_conn = nothing
	set rs = nothing
	
'#################################################


End if 


'#####################################
' Banner click

 If Request.QueryString(&quot;action&quot;) = &quot;click&quot; then

Dim strRef, strBannerID
Dim strLink, strClicked

strRef = Request.QueryString(&quot;ref&quot;)
strBannerId = Request.QueryString(&quot;banner&quot;)

		'########################
		If strBannerId = &quot;&quot; or IsNumeric(strBannerId) <> True then
				For i=1 to 14
					Response.Write &quot;<br>&quot;
				Next
			'######################
			Response.Write &quot;<center>The banner clicked is no longer in the database.</center>&quot;
		End if

	ConnString = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;banner.mdb&quot;)
	set my_conn= Server.CreateObject(&quot;ADODB.Connection&quot;)
	set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

	my_conn.Open ConnString

	sqlSelectBannerID2 = &quot;SELECT * FROM banners WHERE bID=&quot; &  strBannerId
	rs = my_conn.Execute(sqlSelectBannerID2)
	
	strLink = rs(&quot;b_link&quot;)
	strClicked = rs(&quot;b_clicked&quot;)
	
	my_conn.close
	set my_conn = nothing
	set rs = nothing
	
	
	'##############
	'Update Click
	set my_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
	my_conn.Open ConnString

	
	mySQL2 = &quot;UPDATE banners SET &quot; _
		& &quot;b_page = '&quot; & Request.QueryString(&quot;ref&quot;) & &quot;', &quot; _
		& &quot;b_clicked = &quot; & strClicked + 1 & &quot;,  &quot; _
		& &quot;WHERE bID =&quot; & strBannerId

	rs = my_conn.Execute(mySQL2)
	
	my_conn.close
	set my_conn = nothing
	set rs = nothing
	
	
	Response.Redirect(strLink)
	
	End if
	
	%>
 
[tt]Wow, that's alot of code. I usually use this

<script LANGUAGE=&quot;JavaScript&quot;>
<!--Hide

var numImages = 3
var allImages = new Array(numImages)
var i = 0
allImages[0] = new Image()
allImages[0].src = &quot;newlogo1.gif&quot;
allImages[1] = new Image()
allImages[1].src = &quot;newlogo2.gif&quot;
allImages[2] = new Image()
allImages[2].src = &quot;newlogo3.gif&quot;
allImages[3] = new Image()
allImages[3].src = &quot;newlogo4.gif&quot;
allImages[4] = new Image()
allImages[4].src = &quot;newlogo5.gif&quot;


function nextImage() {
document.images[0].src = allImages.src
i = i + 1
if (i>=numImages)
{
i = 0
}
setTimeout(&quot;nextImage()&quot;, 4000)
}
setTimeout(&quot;nextImage()&quot;, 4000)
//Stop Hiding-->
</script>
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top