Forums

ASP

This topic is locked

voting system

Posted 04 May 2001 23:05:37
1
has voted
04 May 2001 23:05:37 suhail kaleem posted:
can anybody tell me what is wrong with the following script it always give me unsipicfied errror .



<%
'Two varibles are passed into the db
'u_input is the value if the user entered a response to
'the vote/poll question....IP is the address of the user
u_input=request.form("u_input"
u_ip=request.servervariables("remote_addr"

' if the user did not enter anything in the poll on this visit
' then display the poll question and possible choices
if u_input = "" then
%>

<form method="post" action="vote_db1.asp">
<p>Question Goes Here<br>
<input type="radio" value="1" name="u_input">1<br>
<input type="radio" value="2" name="u_input" >2<br>
<input type="radio" value="3" name="u_input" checked>3<br>
<input type="radio" value="4" name="u_input">4<br>
<input type="radio" value="5" name="u_input">5<br>
<input type="radio" value="6" name="u_input">6<br>
<input type="radio" value="7" name="u_input">7<br>
<input type="radio" value="8" name="u_input">8<br>
<input type="radio" value="9" name="u_input">9<br>
<input type="radio" value="10" name="u_input">10<br>

<input type="submit" value="Submit" ></p>
</form>

<%
else
' if the user did input a choice on the vote/ballot
' check to see if their ip address is already in the db
accessdb="db/ruhotdb"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset"
sql = "select ip from ballot where ip ='" & u_ip & "'"

rs.Open sql, cn
if rs.eof then
' if the user has not voted previously indicate it
been_here_before="No"
end if
rs.close

if been_here_before = "No" then
' Since the user has not voted previously their input
' their vote will be added to the db

sql = "insert into ballot (ip, pic_rate" & u_input &" "
sql = sql & "values ('" & u_ip & "',1)"
rs.Open sql, cn
end if

'This will summerize and count the records in the db
sql= "select distinctrow sum(pic_rate1) as sum_pic_rate1, "
sql= sql & "sum(pic_rate2) AS sum_pic_rate2, sum(pic_rate3) AS sum_pic_rate3, "
sql= sql & "sum(pic_rate4) AS sum_pic_rate4, sum(pic_rate5) AS sum_pic_rate5, "
sql= sql & "sum(pic_rate6) AS sum_pic_rate6, sum(pic_rate7) AS sum_pic_rate7, "
sql= sql & "sum(pic_rate8) AS sum_pic_rate8, sum(pic_rate9) AS sum_pic_rate9, "
sql= sql & "sum(pic_rate10) AS sum_pic_rate10, count(*) AS total_votes "
sql= sql & "FROM ballot;"
rs.Open sql, cn
total1=rs ("sum_pic_rate1"
total2=rs ("sum_pic_rate2"
total3=rs ("sum_pic_rate3"
total4=rs ("sum_pic_rate4"
total5=rs ("sum_pic_rate5"
total6=rs ("sum_pic_rate6"
total7=rs ("sum_pic_rate7"
total8=rs ("sum_pic_rate8"
total9=rs ("sum_pic_rate9"
total10=rs ("sum_pic_rate10"
count=rs ("total_votes"
%>
<br>
Rate 1<img src="images/red.jpg" height="10" width="<%= (total1/count)*100 %>">
<%= formatnumber((total1/count)*100,1) %>%<br>

Rate 2<img src="images/yellow.jpg" height="10" width="<%= (total2/count)*100 %>">
<%= formatnumber((total2/count)*100,1) %>%<br>

Rate 3<img src="images/green.jpg" height="10" width="<%= (total3/count)*100 %>">
<%= formatnumber((total3/count)*100,1) %>%<br>

Rate 4<img src="images/blue.jpg" height="10" width="<%= (total4/count)*100 %>">
<%= formatnumber((total4/count)*100,1) %>%<br>

Rate 5<img src="images/blue.jpg" height="10" width="<%= (total5/count)*100 %>">
<%= formatnumber((total5/count)*100,1) %>%<br>

Rate 6<img src="images/blue.jpg" height="10" width="<%= (total6/count)*100 %>">
<%= formatnumber((total6/count)*100,1) %>%<br>

Rate 7<img src="images/blue.jpg" height="10" width="<%= (total7/count)*100 %>">
<%= formatnumber((total7/count)*100,1) %>%<br>

Rate 8<img src="images/blue.jpg" height="10" width="<%= (total8/count)*100 %>">
<%= formatnumber((total8/count)*100,1) %>%<br>

Rate 9<img src="images/blue.jpg" height="10" width="<%= (total9/count)*100 %>">
<%= formatnumber((total9/count)*100,1) %>%<br>

Rate 10<img src="images/blue.jpg" height="10" width="<%= (total10/count)*100 %>">
<%= formatnumber((total10/count)*100,1) %>%<br>

Total Votes: <%= formatnumber(count,0,0) %><br>

<% if been_here_before <> "No" then %>
This user has voted before and this one was <u>not</u> counted.....
<% else %>
This user has <u>not</u> voted before and this one was counted.....
<% end if %>
<br>
The I.P. Address is <%= u_ip %>
<% end if %>

please help .

Reply to this topic