|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
cannot get script to work..
Hi,
I need to get this working but I am having the hardest of times. I recreated the An Ariticle Rating System script and here is my problem. I named my table questions and created a colum as the test database included in the files. When I try running the questions.asp page i cant see any of the questions and when I click on rate it...it is asking me to open the rate.asp page. Can someone help I also get the following error... Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /execstaff/poll2003/showques.asp, line 9 since i am testing in my server i copy the file that all the pages are place and create a connection from there...I would appreciate your help....PLEASE! here is my code.... <% dim conn dim rs set conn = Server.CreateObject("ADODB.Connection") set rs = Server.CreateObject("ADODB.Recordset") conn.Open "DSN=questions" rs.ActiveConnection = conn rs.Open "SELECT * FROM questions ORDER BY title ASC" while not rs.EOF %> <font face="Verdana" size="2" color="black"> <h2><%=rs.Fields(1).Value%></h2> Rated: <%=ShowRating(rs.Fields(0).Value)%><br><br> <b>Question:</b> <%=rs.Fields(2).Value%><br> <b>Summary:</b> <%=rs.Fields(3).Value%><br> <b>Category:</b> <%=FormatCurrency(rs.Fields(4).Value, 2)%><br> </font> <br> <form name="frmRate<%=rs.Fields(0).value%>" action="rate.asp" method="post"> <input type="hidden" name="quesId" value="<%=rs.Fields(0).value%>"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="black"> <font face="Verdana" size="1" color="white"> <% for i = 1 to 10 Response.Write " " & i & " <input name='rating' type='radio' value='" & i & "'> " next %> </font> <input type="submit" value="Rate It!"> </td> </tr> </table> </form> <hr size="1" color="#08496B" NOSHADE> <% rs.MoveNext wend function ShowRating(quesId) const MIN_RATINGS_BEFORE_SHOW = 3 dim rs1 dim avgRating dim avgWhole dim decPart dim decCalc dim finalRating dim altText set rs1 = Server.CreateObject("ADODB.Recordset") rs1.ActiveConnection = conn rs1.Open "SELECT SUM(rating), COUNT(*) FROM rating WHERE quesId = " & quesId if rs1.Fields(1) < MIN_RATINGS_BEFORE_SHOW then 'No ratings for this Ques just yet Response.Write "[Ques not rated yet]" else 'This Ques has ratings, let's display the average avgRating = rs1.Fields(0).Value / rs1.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 10" for i = 1 to CInt(finalRating) Response.Write "<img alt='" & altText & "' src='rating_on.gif'>" next if CInt(finalRating) <> finalRating then 'This Question has a .5 rating, such as 5.5 Response.Write "<img alt='" & altText & "' src='rating_half.gif'>" for i = CInt(finalRating)+2 to 5 Response.Write "<img alt='" & altText & "' src='rating_off.gif'>" next else for i = CInt(finalRating)+1 to 5 Response.Write "<img alt='" & altText & "' src='rating_off.gif'>" next end if end if end function %> |
|
#2
|
|||
|
|||
|
Duplicate Thread... Refer to original post
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > cannot get script to work.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|