ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 18th, 2003, 08:57 AM
storm_mind storm_mind is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 45 storm_mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 57 m 14 sec
Reputation Power: 5
if, then & else

I receive the following message error:

Microsoft VBScript compilation error '800a03f6'
Expected 'End'
/panteismo/pollwrite.asp, line 99
else
^
Can someone help me? The file's code is:

<%
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")

if u_input = "" then
response.redirect "poll.html"
else

accessdb="/panteismo/db/poll.mdb"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select ip from votos where ip ='" & u_ip & "'"

rs.Open sql, cn
if rs.eof then
if u_input = "01" then
sql = "insert into votos (ip, selection01) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "02" then
sql = "insert into votos (ip, selection02) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "03" then
sql = "insert into votos (ip, selection03) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "04" then
sql = "insert into votos (ip, selection04) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "05" then
sql = "insert into votos (ip, selection05) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "06" then
sql = "insert into votos (ip, selection06) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "07" then
sql = "insert into votos (ip, selection07) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "08" then
sql = "insert into votos (ip, selection08) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "09" then
sql = "insert into votos (ip, selection09) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "10" then
sql = "insert into votos (ip, selection10) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "11" then
sql = "insert into votos (ip, selection11) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "12" then
sql = "insert into votos (ip, selection12) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "13" then
sql = "insert into votos (ip, selection13) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "14" then
sql = "insert into votos (ip, selection14) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "15" then
sql = "insert into votos (ip, selection15) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "16" then
sql = "insert into votos (ip, selection16) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "17" then
sql = "insert into votos (ip, selection17) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "18" then
sql = "insert into votos (ip, selection18) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "19" then
sql = "insert into votos (ip, selection19) "
sql = sql & "values ('" & u_ip & "',1)"
else
if u_input = "20" then
sql = "insert into votos (ip, selection20) "
sql = sql & "values ('" & u_ip & "',1)"
rs.Open sql, cn
response.redirect "pollresults.asp"
End if
else
response.redirect "polloff.html"
end if%>

Many thanks

Luis

Reply With Quote
  #2  
Old November 18th, 2003, 09:12 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,957 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 15 h 35 m 19 sec
Reputation Power: 802
Count up your "If ..." statements and you "end if" statements, the counts need to match. It's easier to see if you indent. You can use [ code ] or [ php ] forum tags to preserve formatting in your posts here, see the faq.

Reply With Quote
  #3  
Old November 18th, 2003, 09:35 AM
storm_mind storm_mind is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 45 storm_mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 57 m 14 sec
Reputation Power: 5
I think my problem is to balance the if's.

I start with:

if u_input = "" then
response.redirect "poll.html"
else

In this first else, I ask the server to check the ip in a database and if the is is clear than I use 20 if condition (one for each possibility of input) and then redirect the user to pollresults.asp
I close that condition with a End If.
Is the ip is already in the database, i wish to redirect it to pollonce.asp

I think that last condition is coliding with the first else...

Reply With Quote
  #4  
Old November 18th, 2003, 11:28 AM
m3ckon m3ckon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Sheffield UK
Posts: 69 m3ckon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 57 sec
Reputation Power: 5
If I were you I'd use a case statement here instead

M3ckon

Reply With Quote
  #5  
Old November 18th, 2003, 11:41 AM
fused fused is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 78 fused User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
since you are using "ELSE" to control it and and value is fixed from 1 to 20, How about using a For Loop instead?
Code:
For i=1 To 20
  If u_input = i Then
    sql = "insert into votos (ip, selection" & i & ") "
    sql = sql & "values ('" & u_ip & "',1)"
  End If
Next


Please advise if there's any errors above. Thanks.

Another alternative is to use CASE statement

Reply With Quote
  #6  
Old November 18th, 2003, 12:24 PM
storm_mind storm_mind is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 45 storm_mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 57 m 14 sec
Reputation Power: 5
Hi m3ckon and fused,
First of all thank you for your help!
A friend already told me about case statement but I don´t know who it work. I've tried to find something in the internet but without results...
About the code sample you've write, fused, i´m going to try it and then i'll teel you the result... At least, it seems easier that the way I was doing...

Luis

Reply With Quote
  #7  
Old November 18th, 2003, 01:22 PM
INF INF is offline
Standards User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 146 INF User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 4 sec
Reputation Power: 6
fused's approach is probably the best way to go, but so you know a case statement would be like so:
Code:
Select Case u_input
	Case "01"
		sql = "insert into votos (ip, selection01) "
		sql = sql & "values ('" & u_ip & "',1)"
	Case "02"
		sql = "insert into votos (ip, selection02) "
		sql = sql & "values ('" & u_ip & "',1)"
	' ...And So On And So On
End Select

Reply With Quote
  #8  
Old November 19th, 2003, 09:30 AM
storm_mind storm_mind is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 45 storm_mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 57 m 14 sec
Reputation Power: 5
Thank you for the help in the case statement... I've tried it... I don´t receive any error, but it doesn't record any vote... Any sugestion? If you want to see the page online the url is: www32.brinkster.com/panteismo/poll.html

<%
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")

accessdb="/panteismo/db/poll.mdb"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select ip from votos where ip ='" & u_ip & "'"

rs.Open sql, cn
if rs.eof then

Select Case u_input
Case "1"
sql = "insert into votos (ip, selection1) "
sql = sql & "values ('" & u_ip & "',1)"
(...)
Case "20"
sql = "insert into votos (ip, selection20) "
sql = sql & "values ('" & u_ip & "',1)"
End Select
response.redirect "pollresults.asp"
else
response.redirect "pollonce.asp"
end if
%>

Reply With Quote
  #9  
Old November 19th, 2003, 09:35 AM
m3ckon m3ckon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Sheffield UK
Posts: 69 m3ckon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 57 sec
Reputation Power: 5
From this example you're not actually executing the SQL, just assigning the statement to a SQL variable

before response.redirect "pollresults.asp"

Add the lines

rs.close
rs.Open sql, cn,2,3


And this should work

M3ckon

Reply With Quote
  #10  
Old November 19th, 2003, 09:56 AM
storm_mind storm_mind is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 45 storm_mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 57 m 14 sec
Reputation Power: 5
It worked The poll is working fine!!! Thank you very to all who helped me!

Luís (aka Storm)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > if, then & else


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT