hi everyone!
any advice given will be MUCH appreciated, i have spent about 10 hours on this bit of script... a rating system. I am having realt trouble overcoming this problem at runtime
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/ddwassignment2/full_catalogue2 .asp, line 180
please find the complete code listing below, i have highlighted line 180... if you spot any other errors please let me know! The function begins on line: 62
any advice given will be MUCH appreciated, i have spent about 10 hours on this bit of script... a rating system. I am having realt trouble overcoming this problem at runtime
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/ddwassignment2/full_catalogue2 .asp, line 180
please find the complete code listing below, i have highlighted line 180... if you spot any other errors please let me know! The function begins on line: 62
Code:
<%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/music_world.asp" --> <% Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows Set Recordset1_cmd = Server.CreateObject ("ADODB.Command") Recordset1_cmd.ActiveConnection = MM_music_world_STRING Recordset1_cmd.CommandText = "SELECT * FROM tbl_cds" Recordset1_cmd.Prepared = true Set Recordset1 = Recordset1_cmd.Execute Recordset1_numRows = 0 %> <% dim rs1 dim avgRating dim avgWhole dim decPart dim decCalc dim finalRating dim altText %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = 5 Repeat1__index = 0 Recordset1_numRows = Recordset1_numRows + Repeat1__numRows %> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style1 { color: #FF6633; font-weight: bold; } --> </style> </head> <body> <p align="left" class="style1">Full CD catalogue</p> <hr><hr> <p align="left" class="style1"> </p> <div align="left"> <% function ShowRating(cdid) const MIN_RATINGS_BEFORE_SHOW = 1 dim Recordset2 dim avgRating dim avgWhole dim decPart dim decCalc dim finalRating dim altText dim conn set conn = Server.CreateObject("ADODB.Connection") set Recordset2 = Server.CreateObject("ADODB.Recordset") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment2\music_world.mdb" Recordset2 = "SELECT SUM(rating), COUNT(*) FROM ratings WHERE cdid = " & cdid 'This CD has ratings, let's display the average avgRating = Recordset2.Fields(0).Value / Recordset2.Fields(1).Value if Instr(1, CStr(avgRating), ".") > 0 then 'The average rating is a decimal, we need to either 'round the value up/down avgWhole = Left(CStr(avgRating), Instr(1, CStr(avgRating), ".")-1) decPart = Mid(CStr(avgRating), Instr(1, CStr(avgRating), ".")+1, 2) if decPart <> "" then 'Work out whether or not we have to round this 'rating up or down if CInt(decPart) >= 5 then decCalc = .5 else decCalc = 0 end if finalRating = CInt(avgWhole) + CCur(decCalc) else finalRating = avgRating end if else finalRating = avgRating end if 'Setup the alt text for the images altText = "Average visitor rating of " & finalRating & " out of 5" for i = 1 to CInt(finalRating) Response.Write "<img alt='" & altText & "' src='rating_on.gif'>" next if CInt(finalRating) <> finalRating then 'This article has a .5 rating, such as 5.5 Response.Write "<img alt='" & altText & "' src='rating_half.gif'>" for i = CInt(finalRating)+2 to 10 Response.Write "<img alt='" & altText & "' src='rating_off.gif'>" next else for i = CInt(finalRating)+1 to 10 Response.Write "<img alt='" & altText & "' src='rating_off.gif'>" next end if end function if CInt(finalRating) <> finalRating then 'This article has a .5 rating, such as 5.5 Response.Write "<img alt='" & altText & "' src='rating_half.gif'>" %> <h2><%=Recordset2.Fields(0).Value%></h2> <br> <br> <%end if%> <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %> <table width="52%" border="0" cellspacing="4" cellpadding="0"> <tr> <td width="39%" rowspan="6" align="left" valign="top"><img src="images\album_pics\<%=(Recordset1.Fields.Item("cd_image").Value)%>"> <tr> <tr> <td width="39%" rowspan="6" align="left" valign="top"> </td> <td width="28%"><strong>Album:</strong></td> <td width="33%"><div align="left"><%=(Recordset1.Fields.Item("cd_title").Value)%></div></td> </tr> <tr> <td><strong>Artist:</strong></td> <td><div align="left"><%=(Recordset1.Fields.Item("artist_name").Value)%></div></td> </tr> <tr> <td><strong>Release date:</strong></td> <td><div align="left"><%=(Recordset1.Fields.Item("release_date").Value)%></div></td> </tr> <tr> <td><strong>Genre:</strong></td> <td><div align="left"><%=(Recordset1.Fields.Item("music_genre").Value)%></div></td> </tr> <tr> <td><p><strong>Artist Biography</strong>:</p></td> </tr> <tr> <td colspan="3"></td> <tr> <td align="left" valign="top"><%=(Recordset1.Fields.Item("artist_biography").Value)%></td> <td colspan="3"> </td> <tr> <td colspan="5" align="left" valign="top">[B]<div align="right">Rated: <%=ShowRating(Recordset2.Fields(0).Value)%>[/B] </div></td> <tr> <td colspan="4" align="left" valign="top"> <form name="frmRate<%=recordset1.Fields(0).value%>" action="rate.asp" method="post"> <input type="hidden" name="cdid" value="<%=(recordset1.Fields(0).value)%>"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colbgcolor="white"> <p><font face="Verdana" size="3" color="orange"> Dont buy this <input type ="radio" name="rating" value="1" > <input type ="radio" name="rating" value="2" > <input type ="radio" name="rating" value="3" > <input type ="radio" name="rating" value="4" > <input type ="radio" name="rating" value="5" > You must buy this <p> <input type="submit" value="Rate It!"> </p></td> </tr> </table> </form></td> <tr> <td colspan="4" align="left" valign="top"><hr></td> </table> <div align="right"></div> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 Recordset1.MoveNext() Wend %> </div> <p> Next</p> </body> </html> <% Recordset1.Close() Recordset2.Close() Set Recordset1 = Nothing Set Recordset2 = Nothing %> <% %>
Comment