Adaptando el script a mi web me tope con un nuevo error:
objeto Response error 'ASP 0156 : 80004005'
Error de encabezado
/am/metallica/add_valoracion.asp, line 34
Los enbezados HTTP ya están escritas en el explorador cliente. Cualquier cambio en el encabezado HTTP se debe hacer antes de escribir el contenido de la página.
add_valoracion.asp
Código:
<!--#include file="lenguaje.asp" -->
<html>
<head>
<title><% = Titulo %></title>
<link rel="stylesheet" type="text/css" href="estilo1.css">
</head>
<body>
<%
stroconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("" & DB & "tablaturas.mdb")
set oConn = server.createobject("adodb.connection")
oConn.open stroconn
'Recupero el valor del voto y el valor del ID del producto
ID = Request.Querystring("ID")
votos = Request.Querystring("Votos")
'Traigo los votos actuales que tiene el producto para sumarle los nuevos
SQL="SELECT * FROM tablaturas WHERE id = "&ID&" "
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open SQL, oConn,3,1
vact = Cint(Rs("total_votos"))
total = vact + Votos
'Sumamos uno a las votaciones
rating = Cint(Rs("votos"))+1
'Ahora que tengo el total que es lo que recibi de la base mas los votos nuevos actualizo la valoracion del producto segun su ID
SQL = "UPDATE tablaturas Set total_votos = "&total&", votos = "&rating&" WHERE id = "&ID&" "
Set RS = oConn.Execute(SQL)
'Creamos una cookie con el id del producto para que no voten mas de una vez(puro grupo) le damos una semana
Response.Cookies("valoracion")("ID")= ID
Response.Cookies("valoracion").Expires = Now() + 7
%>
<br>
<br>
<br>
<br>
<table width="215" height="22" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td><table width="100%" height="140" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="text"><div align="center">Gracias por tu Voto<br>
<a href="javascript:onClick=window.close()"><br>
Cerrar Ventana </a><br>
</div></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
valoracion_producto.asp
Código:
<!--#include file="lenguaje.asp" -->
<html>
<head>
<title><% = Titulo %></title>
<%
ID = Request.Querystring("ID")
valoracion = Request.Cookies("valoracion")("ID")
%>
<script language="JavaScript">
function Rating(star) {
if (star != "") self.location.href = "add_valoracion.asp?ID=<%=ID%>&Votos=" + star;
return true;
}
// -->
</script>
<link rel="stylesheet" type="text/css" href="estilo1.css">
</head>
<body>
<div align="center">
<span class="text2">Valoración de Productos<br>
</span>Haz click en las estrellas que crees que<br>
representan el valor de votos para el<br>
producto elegido.<br>
<br>
<br>
<table width="215" height="22" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="50" class="text"><a href="javascript:Rating('0')"><img src="<% = Img %>0_star_rating.gif" width="66" height="14" alt="0 Stars" border="0"></a></td>
<td width="154" class="text">No lo compraría</td>
</tr>
<tr>
<td width="50" class="text"><a href="javascript:Rating('1')"><img src="<% = Img %>1_star_rating.gif" width="66" height="14" alt="1 Star" border="0"></a></td>
<td width="154" class="text">Solo lo vería </td>
</tr>
<tr>
<td width="50" class="text"><a href="javascript:Rating('2')"><img src="<% = Img %>2_star_rating.gif" width="66" height="14" alt="2 Stars" border="0"></a></td>
<td width="154" class="text">Algo tiene de bueno </td>
</tr>
<tr>
<td width="50" class="text"><a href="javascript:Rating('3')"><img src="<% = Img %>3_star_rating.gif" alt="3 Stars" width="66" height="14" border="0" align="absmiddle"></a></td>
<td width="154" class="text">OK</td>
</tr>
<tr>
<td width="50" class="text"><a href="javascript:Rating('4')"><img src="<% = Img %>4_star_rating.gif" width="66" height="14" alt="4 Stars" border="0"></a></td>
<td width="154" class="text">Excelente</td>
</tr>
<tr>
<td width="50" class="text"><a href="javascript:Rating('5')"><img src="<% = Img %>5_star_rating.gif" width="66" height="14" alt="5 Stars" border="0"></a></td>
<td width="154" class="text">No puede faltar en el PC </td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</html>
ver.asp
Código:
...
..
.
<%
Dim Conn
Dim strConn
Dim SQL
Dim RS
Dim rate
Set Conn = Server.CreateObject("ADODB.Connection")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("" & DB & "tablaturas.mdb")
Conn.Open strConn
SQL="SELECT * FROM tablaturas ORDER BY id"
set RS = Conn.Execute(SQL)
Do While Not RS.EOF
%>
<table border="0" width="100%">
<tr>
<td width="100%">
<table border="0" width="100%">
<tr>
<td width="85%" class="text"><a href="clicks1.asp?url=<% = RS("URL") %>"><% = RS("cancion") %></a> (<% = RS("formato") %>)</td>
<td width="15%" class="text">Descargas: <% = RS("clicks") %></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%"><% = RS("tamaño") %>KB<br><% = RS("descripcion") %></td>
</tr>
<tr>
<td width="100%"><%
if RS("votos")="0" then
Response.Write ("Este producto ha recibido "&Rs("votos")&" votos ")
Response.Write ("<img src=""" & Img & "0_star_rating.gif"" width=""66"" height=""14"" alt="""&rate&" Estrellas"" border=""0"" align=""absmiddle"">")
Response.Write (" - ")
Response.Write ("<a href=""javascript:openWin('valoracion_producto.asp?ID=" & rs("id") & "','rate_site')"" style=""font-size:""11px""; font-style: italic;"">votar</>")
else
rate = Cint(Rs("total_votos"))/Cint(Rs("votos"))
rate = Round(rate)
Response.Write ("Este producto ha recibido "&Rs("votos")&" votos ")
Response.Write ("<img src=""" & Img & "" & rate & "_star_rating.gif"" width=""66"" height=""14"" alt="""&rate&" Estrellas"" border=""0"" align=""absmiddle"">")
Response.Write (" - ")
Response.Write ("<a href=""javascript:openWin('valoracion_producto.asp?ID=" & rs("id") & "','rate_site')"" style=""font-size:""11px""; font-style: italic;"">votar</>")
end if
%></td>
</tr>
</table><br><br>
<%
RS.MoveNext
Loop
%>
.
..
...
y no se porque el error si solo cambie
Response.Cookies("valoracion")("prodID")= prodID por
Response.Cookies("valoracion")("ID")= ID