oversoul
01-26-2005, 11:45 PM
Hello, I am trying to make a form show at a specific time everday on my webpage. I am inserting the numbers of the the time in a database and posting it to the page. For some reason this is not working for me.
here is my code to help understand what I am doing.
<%
Dim thehour, Theminute, Thesecond
thehour=Hour(now) ' Here we will add 1 to hour in server to make it Central Time
if thehour>12 then
thehour=thehour-12
end if
Theminute=minute(now)
if Theminute<10 then
Theminute="0" & Theminute
end if
Thesecond=second(now)
if Thesecond<10 then
Thesecond="0" & Thesecond
end if
%>
The time is: <%=thehour %>:<%=Theminute %>:<%=Thesecond %><br>
<%
'declare your variables
Dim sSQL, sconnection, srecordset
'declare SQL statement that will query the database
sSQL="SELECT * FROM tblTimes"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("access/Totals.mdb")
'create an ADO connection and recordset
Set sconnection = Server.CreateObject("ADODB.Connection")
Set srecordset = Server.CreateObject("ADODB.Recordset")
'Open the connection to the database
sconnection.Open sConnString
'Open the recordset object, execute the SQL statement
srecordset.Open sSQL, sconnection
Dim var1, var2, var3, var4
var1 = Hour(now)
var2 = Hour(now)
var3 = minute(now)
var4 = minute(now)
If (var1>=0) and (var2<=srecordset("bstart")) and (var3<=srecordset("mbstart")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
If (var1>=srecordset("MainStart")) and (var3<=srecordset("MainMin")) and (var2<=srecordset("MainEnd")) and (var4<=srecordset("MainEndMin")) Then
Response.write("<br>")
Response.write("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='36%'>")
Response.write("<tr>")
Response.write("<td width='18%'>")
Response.write("<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>")
Response.write("<p align='center'>")
Response.write("<input type='hidden' name='cmd' value='_xclick'>")
Response.write("<input type='hidden' name='business' value='info@my-domain.com'>")
Response.write("<input type='hidden' name='item_name' value='1 Day Purchase'>")
Response.write("<input type='hidden' name='amount' value='10.00'>")
Response.write("<input type='hidden' name='no_note' value='1'>")
Response.write("<input type='hidden' name='currency_code' value='USD'>")
Response.write("<input type='hidden' name='notify_url' value='http://www.my-domain.com/validate.asp'>")
Response.write("<input type='hidden' name='return' value='http://www.my-domain.com/confirmation.asp'>")
Response.write("<input type='image' src='images/x-click-but23.gif' border='0' name='submit' align='right'>")
Response.write("<input type='hidden' name='add' value='1'>")
Response.write("</form>")
Response.write("</td>")
Response.write("<td width='182%' align='center'>")
Response.write("<font face='Verdana'><b>$10.00</b></font>")
Response.write("</td>")
Response.write("</tr>")
Response.write("</table>")
Else If (var1>=srecordset("AfterMain")) and (var3>=srecordset("AfterMainMin")) and (var2<=srecordset("EndingAfterMain")) and (var4>=srecordset("EndingAfterMainMin")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has already begun.</b></font>")
Else If (var1>=srecordset("Final1")) and (var3>=srecordset("Final1Min")) and (var2<=srecordset("Final2")) and (var4>=srecordset("Final2Min")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
End If
End If
End If
End If
%>
After all of this, It only runs the first if then portion and none of the others. Why is ti doing this?
Please help, this is urgent....
here is my code to help understand what I am doing.
<%
Dim thehour, Theminute, Thesecond
thehour=Hour(now) ' Here we will add 1 to hour in server to make it Central Time
if thehour>12 then
thehour=thehour-12
end if
Theminute=minute(now)
if Theminute<10 then
Theminute="0" & Theminute
end if
Thesecond=second(now)
if Thesecond<10 then
Thesecond="0" & Thesecond
end if
%>
The time is: <%=thehour %>:<%=Theminute %>:<%=Thesecond %><br>
<%
'declare your variables
Dim sSQL, sconnection, srecordset
'declare SQL statement that will query the database
sSQL="SELECT * FROM tblTimes"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("access/Totals.mdb")
'create an ADO connection and recordset
Set sconnection = Server.CreateObject("ADODB.Connection")
Set srecordset = Server.CreateObject("ADODB.Recordset")
'Open the connection to the database
sconnection.Open sConnString
'Open the recordset object, execute the SQL statement
srecordset.Open sSQL, sconnection
Dim var1, var2, var3, var4
var1 = Hour(now)
var2 = Hour(now)
var3 = minute(now)
var4 = minute(now)
If (var1>=0) and (var2<=srecordset("bstart")) and (var3<=srecordset("mbstart")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
If (var1>=srecordset("MainStart")) and (var3<=srecordset("MainMin")) and (var2<=srecordset("MainEnd")) and (var4<=srecordset("MainEndMin")) Then
Response.write("<br>")
Response.write("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='36%'>")
Response.write("<tr>")
Response.write("<td width='18%'>")
Response.write("<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>")
Response.write("<p align='center'>")
Response.write("<input type='hidden' name='cmd' value='_xclick'>")
Response.write("<input type='hidden' name='business' value='info@my-domain.com'>")
Response.write("<input type='hidden' name='item_name' value='1 Day Purchase'>")
Response.write("<input type='hidden' name='amount' value='10.00'>")
Response.write("<input type='hidden' name='no_note' value='1'>")
Response.write("<input type='hidden' name='currency_code' value='USD'>")
Response.write("<input type='hidden' name='notify_url' value='http://www.my-domain.com/validate.asp'>")
Response.write("<input type='hidden' name='return' value='http://www.my-domain.com/confirmation.asp'>")
Response.write("<input type='image' src='images/x-click-but23.gif' border='0' name='submit' align='right'>")
Response.write("<input type='hidden' name='add' value='1'>")
Response.write("</form>")
Response.write("</td>")
Response.write("<td width='182%' align='center'>")
Response.write("<font face='Verdana'><b>$10.00</b></font>")
Response.write("</td>")
Response.write("</tr>")
Response.write("</table>")
Else If (var1>=srecordset("AfterMain")) and (var3>=srecordset("AfterMainMin")) and (var2<=srecordset("EndingAfterMain")) and (var4>=srecordset("EndingAfterMainMin")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has already begun.</b></font>")
Else If (var1>=srecordset("Final1")) and (var3>=srecordset("Final1Min")) and (var2<=srecordset("Final2")) and (var4>=srecordset("Final2Min")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
End If
End If
End If
End If
%>
After all of this, It only runs the first if then portion and none of the others. Why is ti doing this?
Please help, this is urgent....