Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal bom dia! Minha enquete está exibindo a questão e as opções de voto, mas quando efetuo a votação dá erro. Alguém pode me ajudar? Seguem os CODES abaixo.
Ps:
bando de dados em MySql;
tabela: enquete;
colunas: Poll_ID, Poll_Question, Option_1, Option_2, Option_3, Option_4, Option_5, Votes_1, Votes_2, Votes_3, Votes_4, Votes_5, Status
enquete.asp
<!--#include file="conectar.asp"--><LINK href="../arquivos/style.css" type=text/css rel=stylesheet><script LANGUAGE=JavaScript><!--<!--function OptionChecked() { var i; for (i = 0; i < document.frmPoll.radPoll.length; i++) if (document.frmPoll.radPoll[i].checked) return true; alert("Você deve selecionar alguma opção"); return false; }// -->function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}//--></SCRIPT><%'iniciar a seleçãoAbreConexaolistar = "SELECT * FROM enquete WHERE Status = 'Ativa' "Set lista = Conexao.Execute(listar)'Set RS = Server.CreateObject("ADODB.Recordset")'RS.Open strQuery, db, 3,3%><%strVoted = cstr(Request.Cookies("JCPoll"))if strVoted <> cstr(lista("poll_id")) then 'mostra a questao da enquete%> <title><%=lista("Poll_Question")%></title><body bgcolor="#A8A89E" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('bt_votar.gif','cinza.gif')"><table width="145" height="143" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="34"> <table width="145" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="4"> </td> <td width="116"><span class="texto"><%=lista("Poll_Question")%></span></td> </tr> </table></td> </tr> <tr> <td height="12"></td> </tr> <tr> <td><FORM METHOD=POST ACTION="votar.asp" ONSUBMIT="return OptionChecked();" NAME=frmPoll> <% for t = 1 to 5 VoteOption = "Option_" & t If lista(VoteOption) <> "" then %> <INPUT TYPE=RADIO NAME=radPoll VALUE="<%=t%>"> <span class="texto"><%=lista(VoteOption)%></span><BR> <% end if next 't %> <CENTER> <br> <br> <input name="imageField" type="image" src="bt_votar.gif" width="44" height="20" border="0"> </CENTER> </form></td> </tr></table> <%else 'mostra os resultados da enquete%><table width="145" height="203" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="27"> <table width="145" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="4"> </td> <td width="76"><span class="texto"><%=lista("Poll_Question")%></span></td> </tr> </table></td></tr> <tr> <td> <% TotalVotes = lista("Votes_1") + lista("Votes_2") + lista("Votes_3") + lista("Votes_4") + lista("Votes_5") %> <% for t = 1 to 5 VoteOption = "Option_" & t BarWidth = "Votes_" & t If lista(VoteOption) <> "" then %> <span class="texto"><%=lista(VoteOption)%> (<%=FormatPercent(lista(BarWidth)/TotalVotes)%>)</span> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD><img src = "cinza.gif" height="4" WIDTH=<%=CInt((lista(BarWidth)/TotalVotes)*150)%>> </TD> </TR> </TABLE> <% end if next 't %> <span class="texto">Total de Votos: <%=TotalVotes%></span> <% End Iflista.closeset lista = nothingFechaConexao%></td> </tr></table>
conectar.asp
<%Set Conexao = CreateObject("ADODB.CONNECTION")ConStr = "Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=bd_site; UID=meulogin; PWD=minhasenha;" Conexao.CursorLocation = 3ConexaoAberta = FALSESub AbreConexao() if not ConexaoAberta then Conexao.Open ConStr ConexaoAberta = True end ifend subSub FechaConexao() if ConexaoAberta then Conexao.close ConexaoAberta = False end ifend sub %>
votar.asp
<!--#include file="conectar.asp"--><% @LANGUAGE = VBScript %><% if Request.Form("radpoll") = "" then response.redirect "enquete.asp"%><%'abre o bd para pegar informacoesAbreConexaolistar = "SELECT FROM enquete WHERE Status = 'Ativa' "Set lista = Conexao.Execute(listar)%><%POLLID = lista("Poll_ID") UserSelected = "Votes_" & Request.Form("radpoll")for t = 1 to 5VoteOption = "Votes_" & tif VoteOption = UserSelected then lista = "UPDATE enquete SET " & VoteOption & " = " & (lista(VoteOption) +1) &_ " WHERE Poll_ID = " & POLLID end ifnext 'tdb.execute ( lista )lista.closelistar = "SELECT FROM enquete WHERE Poll_ID = " & POLLID & ""lista.Open listarResponse.Cookies("JCPoll") = trim(POLLID)'Response.Cookies("JCPoll").Expires = objRS("End_Date")lista.closeset lista = nothing'db.close'set db = nothingFechaConexaoResponse.Redirect Request.ServerVariables("HTTP_REFERER")%>
O erro é o esse:---------------------------------------------------------------------------------------------------No title aparece: HTTP 500 - erro interno do servidorA página não pode ser exibidaHá um problema com a página que você está tentando acessar e ela não pode ser exibida.-------------------------------------------------------------------------------------------------------Hargon eu acabei de trocar a linha que você se referiu e coloquei:Set votacao = Conexao.execute ( lista ) mas dá dando o mesmo erro.
desabilite as mensagens amigaveis do browser pra ver os detalhes do erro
onde eu faço isso J ?Aqui pelo navegador mesmo?Vi aqui na aba de configurações do navagador, a opção Mostrar mensagens amigáveis, está desmarcado.Lá no plesk também tá ativado pra mostrar os detalhes do erro.
será que tem como fazer algum script dentro do código pra forçar a mostrar qual o erro, o número do erro... essas coisas?
já que você utiliza o plesk, dê uma olhada no arquivo de Log do servidor
Bom, como o log tá bem grandinho... eu acho que a parte do log que acho que interessa é essa:
================================
#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2007-05-30 12:26:51
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken
2007-05-30 12:26:50 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 GET /enquete/enquete.asp - 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) - - www.radioagitabrasil.com 200 0 0 2262 392 1875
2007-05-30 12:26:51 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 GET /arquivos/style.css - 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) ASPSESSIONIDCCTARSTT=CMGFMGLCJJLPNHEJFNMAFBKK http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 200 0 64 0 436 375
2007-05-30 12:26:52 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 GET /enquete/bt_votar.gif - 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) ASPSESSIONIDCCTARSTT=CMGFMGLCJJLPNHEJFNMAFBKK http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 200 0 0 549 438 562
2007-05-30 12:26:52 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 GET /enquete/cinza.gif - 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) ASPSESSIONIDCCTARSTT=CMGFMGLCJJLPNHEJFNMAFBKK http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 200 0 0 299 435 421
2007-05-30 12:27:02 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 POST /enquete/votar.asp |3|ASP_0140|Page_Command_Out_Of_Order 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) ASPSESSIONIDCCTARSTT=CMGFMGLCJJLPNHEJFNMAFBKK http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 500 0 0 572 642 468
2007-05-30 12:40:10 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 POST /enquete/votar.asp |3|ASP_0140|Page_Command_Out_Of_Order 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) - http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 500 0 0 572 587 734
2007-05-30 12:45:35 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 POST /enquete/votar.asp |3|ASP_0140|Page_Command_Out_Of_Order 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) - http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 500 0 0 572 588 437
2007-05-30 12:46:54 W3SVC22553 EV1SERVE-Y4LPEW 67.15.122.22 POST /enquete/votar.asp |3|ASP_0140|Page_Command_Out_Of_Order 80 - 200.223.95.2 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) - http://www.radioagitabrasil.com/enquete/enquete.asp www.radioagitabrasil.com 500 0 0 572 587 406
========================================
O erro deve estar nesta linha:
|3|ASP_0140|Page_Command_Out_Of_Order 80 - 200.223.95.2 HTTP/1.1
sim.... então o erro deve tá no arquivo votar.asp não é isso?
Me ajudem aí namoral.
Vou testando aqui algumas possibilidades, qualquer avanço vou postar aqui pra vcs verem.
retire essa linha de votar.asp, o erro está na linha 3
<% @LANGUAGE = VBScript %>
The @ command must be the first command within the Active Server Page.
Tirei o <% @LANGUAGE = VBScript %> do arquivo votar.asp mas continua com o mesmo problema.
Acabei de tentar criar um arquivo resultado.asp pra desvincular do arquivo enquete.asp, só que deu o mesmo erro do votar.asp Segue o CODE:
resultado.asp
<!--#include file="conectar.asp"--><LINK href="../arquivos/style.css" type=text/css rel=stylesheet><%'iniciar a seleçãoAbreConexaolistar = "SELECT * FROM enquete WHERE Status = 'Ativa' "Set lista = Conexao.Execute(listar)%><table width="145" height="203" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="27"> <table width="145" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="4"> </td> <td width="76"><span class="texto"><%=lista("Poll_Question")%></span></td> </tr> </table></td></tr> <tr> <td> <% TotalVotes = lista("Votes_1") + lista("Votes_2") + lista("Votes_3") + lista("Votes_4") + lista("Votes_5") %> <% for t = 1 to 5 VoteOption = "Option_" & t BarWidth = "Votes_" & t If lista(VoteOption) <> "" then %> <span class="texto"><%=lista(VoteOption)%> (<%=FormatPercent(lista(BarWidth)/TotalVotes)%>)</span> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD><img src = "cinza.gif" height="4" WIDTH=<%=CInt((lista(BarWidth)/TotalVotes)*150)%>> </TD> </TR> </TABLE> <% end if next 't %> <span class="texto">Total de Votos: <%=TotalVotes%></span> <% End Iflista.closeset lista = nothingFechaConexao%></td> </tr></table>Pessoal novidades:fiz uma pequena subtração de algumas coisas no código do arquivo resultado.asp e está tudo funcionando direitinho.Já o arquivo votar.asp está inserindo o voto no banco de dados, mas n faz o redirect para o resultado.
pessoal consegui resolver o problema.
Fiz umas plásticas aqui e no final ficou uma beleza.
Vou mostrar como foi a cirurgia:
No arquivo votar.asp eu modifiquei o redirect e ranquei alguns componentes to tipo lista.close (algo que estava sendo fechado sem ao menos ter sido aberto antes). Ficou assim:
<!--#include file="conectar.asp"--><% if Request.Form("radpoll") = "" then response.redirect "enquete.asp"%><%'abre o bd para pegar informacoesAbreConexaolistar = "SELECT * FROM enquete WHERE Status = 'Ativa' "Set lista = Conexao.Execute(listar)%><%POLLID = lista("Poll_ID") UserSelected = "Votes_" & Request.Form("radpoll")for t = 1 to 5VoteOption = "Votes_" & tif VoteOption = UserSelected thenlista = "UPDATE enquete SET " & VoteOption & " = " & (lista(VoteOption) +1) &_" WHERE Poll_ID = " & POLLID end ifnext 'tFechaConexaoresponse.redirect "resultado.asp"%>
Já o arquivo resultado.asp eu tirei alguns "end if" e outros componentes que n estavam fazendo sentido algum. Esse arquivo resultado.asp foi parido (digamos assim) do arquivo enquete.asp que pra melhorar minhas experiências, decidi dividir as coisas pra ter uma noção melhor. O dito cujo ficou assim:
<!--#include file="conectar.asp"--><LINK href="../arquivos/style.css" type=text/css rel=stylesheet><%'iniciar a seleçãoAbreConexaolistar = "SELECT * FROM enquete WHERE Status = 'Ativa' "Set lista = Conexao.Execute(listar)%><script language="JavaScript" type="text/JavaScript"><!--function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}//--></script></html><head><title><%=lista("Poll_Question")%></title></head><body bgcolor="#A8A89E" leftmargin="4" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('cinza.gif')"><table width="145" height="94" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="27"> <table width="145" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><span class="texto"><%=lista("Poll_Question")%></span></td> </tr> </table></td></tr> <tr> <td> <% TotalVotes = lista("Votes_1") + lista("Votes_2") + lista("Votes_3") + lista("Votes_4") + lista("Votes_5") %> <% for t = 1 to 5 VoteOption = "Option_" & t BarWidth = "Votes_" & t If lista(VoteOption) <> "" then %> <table width="145" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="30"> <span class="texto"><b><%=lista(VoteOption)%></b> - <%=FormatPercent(lista(BarWidth)/TotalVotes)%></span> <TABLE width="50" BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD><img src = "cinza.gif" height="4" WIDTH=<%=CInt((lista(BarWidth)/TotalVotes)*150)%>></TD> </TR> </TABLE></td> </tr> </table> <% end if next 't %> <span class="texto">Total de Votos: <%=TotalVotes%></span> <% lista.closeset lista = nothingFechaConexao%> </td> </tr></table></body></html>
Sintam-se avontade para se degustarem com o código. Lembrando que é para bd mysql e suporta múltiplos votos de um único usuário (sem limites). Um abraço e obrigado a quem respondeu ao post.
Qual a mensagem de erro?
O que é essa linha db.execute ( lista ) ? Ao inves de db não seria Conexao?
Set votacao = Conexao.execute ( lista )