Ir para conteúdo
Fórum Script Brasil
  • 0

Banner Rotator


X.bArArA.X

Pergunta

Tipo, tenho esse código aqui:

<%

' Set some general variables
BackgroundColor = "ffffff" ' background color of the page (hex value)
sDataSource = "c:\_servidor\new\bannerright\banners.mdb" ' Local Path to Database


' Open Database Access Connection
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & sDataSource

mySQL="SELECT * FROM banners"

set rs=Server.CreateObject("adodb.recordset")
rs.open mySQL, Con, 3

BannersRecordCount=rs.recordcount

randomize()

dim RandomNumber
dim upperbound
dim lowerbound

upperbound = BannersRecordCount
lowerbound = 1

' Get a random record number between 1 and number of banners available
RandomNumber = int ((upperbound - lowerbound + 1)  * rnd + lowerbound)

set rs=Server.CreateObject("adodb.recordset")

    ' Open Static RecordSet
    ' Equivalent values of adOpenKeyset, adLockPessimistic, adCmdTable
    ' from the adovbs.inc file which I haven't included here
    
    rs.open "banners", Con, 1, 2, &H0002
    
    ' Move to the first record ready to cycle through them
    rs.movefirst

' Cycle through the banners until we've got the n'th one
' We can't do this with a SELECT statement as the record
' with an ID matching the RandomNumber may have been delete.
dim intLoop

For intLoop = 1 To RandomNumber - 1
 rs.movenext
next



response.write "<HTML>"

response.write "<HEAD>"

response.write "</HEAD>"
response.write "<BODY bgcolor='#" & BackgroundColor & "' topmargin='0' leftmargin='0'>" 
response.write "<p style='vertical-align: text-top; border: 0px; margin-top: 0px; padding-top: 0px; padding-bottom: 0px'"
response.write "align='center'><a href='" & rs.fields("BannerURL") & "' target='main'>"
response.write "<img border='0' src='" & rs.fields("BannerImage") & "'"
response.write " width='" & rs.fields("BannerWidth") & "' height='" & rs.fields("BannerHeight") & "'></a></p>"
response.write "</BODY>"
response.write "</HTML>"

' Increment the display count for this banner
dim current
current = rs.Fields("BannerDisplayCount")+ 1
rs.Fields("BannerDisplayCount")= current
rs.update

' Check to see if the banner has expired - if it has delete its record
if rs.fields("BannerExpiryDate") < date() then
    ' Delete the record - the 1 is the equivalent value of adAffectCurrent
    ' from the adovbs.inc file which I haven't included here
    rs.Delete 1
end if

' Finished with the recordset now - so close it
con.close
set con=nothing
%>
Está funcionando perfeitamente quando tem apenas este código. Porém, são vários banners na mesma page. Então coloquei várias vezes no mesmo código. Aí surgi o problema, esta mensagem:
Erro de compilação do Microsoft VBScript error '800a0411' 

Redefinição do nome 

/new/bannerright/banners.asp, line 22 

dim RandomNumber
----^

Por favor, ajudem! Está complicado achar um sistema de banner bom, já que não sei fazer! :(

Link para o comentário
Compartilhar em outros sites

16 respostass a esta questão

Posts Recomendados

  • 0

Cara N SB tem o Sistema Troca banner q é muito bom pra nos Webmaters!! Aproveite q é gratis e se cadastre!!! e faça bom proveito do Sistema de Troca de Banner!!!

falou!

:D

Link para o comentário
Compartilhar em outros sites

  • 0

iche ai é problema!!! o site ser do chefe!! mas tipo eu tava olhando por volta da linah 22 ten a seguinet instração "randomize()" eu axo q você deveria passar o parametro q você quer ramdomizar!!! pode ser isso mas essa msg de erro não parec ser isso mas tente por essa linha em comentario e execultar!!!!!

falou! :D

Link para o comentário
Compartilhar em outros sites

  • 0

Cara mas no script q ele postou akelas variaveis não foram declaradas 2x pelo menos não achei a segunda vez!! mas en todo caso, X.bArArA.X coloque uam aspa simples ' antes dessas treis linhas:

dim RandomNumber

dim upperbound

dim lowerbound

ou seja deixe elas assim:
'dim RandomNumber

'dim upperbound

'dim lowerbound

ve se é isso =)

:D

Link para o comentário
Compartilhar em outros sites

  • 0

Aezzzzzzzzzzzzzzzzz resopi... Deu certinho! Vlewz...! Porém tive que adicionar aspas simples em outros dim que encontrei no código. Vlewz, caicai.

Agora estou com outra dúvida que tá me ferrando.

Tipo, nesse meu código, ele pede para indicar o caminho completo. Quando coloco no server, dá pau. Tipo, o diretório principal do site é "../". Dae já vem os arquivos, inclusive a index.asp. Tentei indicar através do http, mas não adiantou. Tentei tudo possível! E agora o que faço?

<%

' Set some general variables

BackgroundColor = "ffffff" ' background color of the page (hex value)

sDataSource = "c:\_servidor\new\bannerright\banners.mdb" ' Local Path to Database

' Open Database Access Connection

Set Con = Server.CreateObject( "ADODB.Connection" )

Con.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & sDataSource

mySQL="SELECT * FROM banners"

set rs=Server.CreateObject("adodb.recordset")

rs.open mySQL, Con, 3

BannersRecordCount=rs.recordcount

randomize()

dim RandomNumber

dim upperbound

dim lowerbound

upperbound = BannersRecordCount

lowerbound = 1

' Get a random record number between 1 and number of banners available

RandomNumber = int ((upperbound - lowerbound + 1) * rnd + lowerbound)

set rs=Server.CreateObject("adodb.recordset")

' Open Static RecordSet

' Equivalent values of adOpenKeyset, adLockPessimistic, adCmdTable

' from the adovbs.inc file which I haven't included here

rs.open "banners", Con, 1, 2, &H0002

' Move to the first record ready to cycle through them

rs.movefirst

' Cycle through the banners until we've got the n'th one

' We can't do this with a SELECT statement as the record

' with an ID matching the RandomNumber may have been delete.

dim intLoop

For intLoop = 1 To RandomNumber - 1

rs.movenext

next

response.write "<HTML>"

response.write "<HEAD>"

response.write "</HEAD>"

response.write "<BODY bgcolor='#" & BackgroundColor & "' topmargin='0' leftmargin='0'>"

response.write "<p style='vertical-align: text-top; border: 0px; margin-top: 0px; padding-top: 0px; padding-bottom: 0px'"

response.write "align='center'><a href='" & rs.fields("BannerURL") & "' target='main'>"

response.write "<img border='0' src='" & rs.fields("BannerImage") & "'"

response.write " width='" & rs.fields("BannerWidth") & "' height='" & rs.fields("BannerHeight") & "'></a></p>"

response.write "</BODY>"

response.write "</HTML>"

' Increment the display count for this banner

dim current

current = rs.Fields("BannerDisplayCount")+ 1

rs.Fields("BannerDisplayCount")= current

rs.update

' Check to see if the banner has expired - if it has delete its record

if rs.fields("BannerExpiryDate") < date() then

' Delete the record - the 1 is the equivalent value of adAffectCurrent

' from the adovbs.inc file which I haven't included here

rs.Delete 1

end if

' Finished with the recordset now - so close it

con.close

set con=nothing

%>

Link para o comentário
Compartilhar em outros sites

  • 0

Olha cara Se a pagina estiver no mesmo diretorio que esta a pagina você pode colocar apenas:

sDataSource = "banners.mdb"

falou!

Link para o comentário
Compartilhar em outros sites

  • 0

:D olá desculpa a demora mas tente:

sDataSource = Request.ServerVariables("PATH_TRANSLATED") & "/banners.mdb"

:D falou

Link para o comentário
Compartilhar em outros sites

  • 0

Vlewz, resopi, mas não resolveu. Olha só os erros:

sDataSource = Request.ServerVariables("PATH_TRANSLATED") & "/bannertop/banners.mdb"

Microsoft JET Database Engine error '80004005'

'D:\inetpub\wwwrootbonesecia\teste\index.asp\bannertop\banners.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

/teste/bannertop/banners.asp, line 11

sDataSource = Request.ServerVariables("PATH_TRANSLATED") & "'D:\inetpub\wwwrootbonesecia\teste\bannertop\banners.mdb'"

Microsoft JET Database Engine error '80004005'

Not a valid file name.

/teste/bannertop/banners.asp, line 11

Entenda o seguinte... teste é o nome da pasta onde estão todas pages. A index.asp tem um include (top.htm) que está dentro da pasta teste/includes. Este top.htm por sua ver, tem outro include teste/bannertop/banners.asp. Dentro desta mesma pasta está o banners.asp.

Link para o comentário
Compartilhar em outros sites

  • 0

Coloquei tudo na mesma pasta e essa b*** não funciona. O phodaz é q não acho um sistema de banners q c encaixe ao meu layout. Achei um bom. Porém, não tem escolher o tamanho da imagem. DAe já ferrou. Agora esse não acha o banco de dados sem q coloque o caminho todo. Q merda! :( :angry:

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...