Author |
Topic |
redbrad0
Advanced Member
USA
3725 Posts |
Posted - 20 October 2003 : 23:15:11
|
Just use the following sub and then call it out like....
Call displaydays(Request.Querystring("days"))
sub displaydays(fdays)
%><font color="#E9E4B4" face="Verdana" size="1">In the last <%=fdays%> days <font color="red"><b>
<%
'## Forum_SQL - Get 60 day data from DB #######################
strtempdays = DateToStr(DateAdd("d",-fdays,Now()))
strSql = "SELECT COUNT(MEMBER_ID) AS NAME_COUNT FROM FORUM_MEMBERS WHERE M_DATE > '" & strtempdays & "' "
set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
response.write rs("name_count")
rs.close
set rs = nothing
%>
</font></b> new members have joined <i>The Battle Group</i> and <font color = "red"><b>
<%
strSql = "SELECT COUNT(start_date) AS GAME_COUNT FROM GAMES WHERE Start_Date > #" & DateAdd("d",-fdays,Now()) & "# and type='ladder duel'"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
response.write rs("GAME_COUNT")
rs.close
set rs = nothing
%>
</font></b>Ladder Duels and <font color = "red"><b>
<%
strSql = "SELECT COUNT(start_date) AS NOW_COUNT FROM games WHERE Start_Date > #" & DateAdd("d",-fdays,Now()) & "# and (type='local attack' or type='campaign attack')"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
response.write rs("NOW_COUNT")
rs.close
set rs = nothing
%>
</font></b>
Local Attacks have been launched!
</td></tr></table>
<%
end sub
|
Brad Oklahoma City Online Entertainment Guide Oklahoma Event Tickets |
|
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 21 October 2003 : 00:16:59
|
redbrad0: I placed your code, but still don't know how to call it now from the links.quote: <font color="#E9E4B4" face="Verdana" size="1">Statistics for><a href='news.asp?=7'>7,</a> <a href='news.asp?=30'>30,</a><a href='news.asp?=60'>60,</a><a href='news.asp?=90'>90</a>days:</font></td>
Where does this go: quote: <% Call displaydays(Request.Querystring("days")) %>
I have updated the .txt file: http://www.ggholiday.com/bg/forums/news.txt |
Alfred The Battle Group CREDO
|
|
|
redbrad0
Advanced Member
USA
3725 Posts |
Posted - 21 October 2003 : 10:02:27
|
Change your links to....
<font color="#E9E4B4" face="Verdana" size="1">Statistics for><a href='news.asp?days=7'>7,</a> <a href='news.asp?days=30'>30,</a><a href='news.asp?days=60'>60,</a><a href='news.asp?days=90'>90</a>days:</font></td>
Just put
Call displaydays(Request.Querystring("days"))
Where you want it to display how many days to view
|
Brad Oklahoma City Online Entertainment Guide Oklahoma Event Tickets |
|
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 21 October 2003 : 11:42:58
|
Ok, I think I have all in the right place now, because it displays as expected. But each link option gives the same error: quote: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /BG/forums/news.asp, line 14
Why is that now? When I include the config.asp in the news.asp file I get a different error: quote: Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'DateToStr' /BG/forums/news.asp, line 111
text file is updated. http://www.ggholiday.com/bg/forums/news.txt
|
Alfred The Battle Group CREDO
|
Edited by - Alfred on 21 October 2003 14:19:24 |
|
|
redbrad0
Advanced Member
USA
3725 Posts |
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 22 October 2003 : 15:34:08
|
When I include both of these files I get this error: quote: Error Type: Microsoft VBScript compilation (0x800A0411) Name redefined /BG/forums/inc_adovbs.asp, line 14, column 6 Const adOpenForwardOnly = 0 -----^
which I remember getting when include files are doubled up.
Without including any file i the news.asp I get a correct display, but the links will give the error when clicked on.
BTW, I noticed that the whole page has to be reloaded for each link option, just as was explained to me by D3mon earlier. So, my question is what is the advantage of coding it this way as opposed to standard htm links to separate files? |
Alfred The Battle Group CREDO
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 22 October 2003 : 15:37:51
|
quote: Originally posted by Alfred
So, my question is what is the advantage of coding it this way as opposed to standard htm links to separate files?
Why have separate files when you can just have one? Takes up less room on your server and you can also add additional links (like for in the past 3082 days if you desire) without having to make a whole new page. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
|
|
redbrad0
Advanced Member
USA
3725 Posts |
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 22 October 2003 : 21:09:18
|
I understand, and that was what I expected as the reasons. Of course, I would always prefer to do correct and economical coding whenever I can manage, but this baby has given so much trouble and I was ready to concede that I had been over ambitious once again. |
Alfred The Battle Group CREDO
|
|
|
redbrad0
Advanced Member
USA
3725 Posts |
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 22 October 2003 : 22:18:56
|
Well, I am game. As I said above, the page now looks as it should, but when any option is clicked it brings up this error: quote: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /BG/forums/news.asp, line 14
Since the two files (config.asp and inc_func_common.asp) are already included in the default page, I should not include them again in the news.asp. So what am I to do now? |
Alfred The Battle Group CREDO
|
|
|
redbrad0
Advanced Member
USA
3725 Posts |
Posted - 22 October 2003 : 22:25:21
|
you said they are included in the default.asp page, but is the default.asp page included in the news.asp?
you have to include the files used in each asp page when and subs are used in that page. you really dont want to include the default.asp page since that is a page that displays data when its being run |
Brad Oklahoma City Online Entertainment Guide Oklahoma Event Tickets |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 22 October 2003 : 22:32:13
|
redbrad, his news pages is an include in his default page.
alfred, you might be getting the error if you are establishing a connection to the database after one already has been established. the inc_header file establishes a connections, so if you are including your news file after you include inc_header, then that's where your error comes from. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
|
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 22 October 2003 : 22:57:07
|
Oh, I have to check that out, Nikkol.
The new.asp is actually included in the inc_header.asp, which is included in the default.asp.
Is this correct then: I do not need to open a connection in news.asp, because it should still be open in default.asp and/or inc_header.asp? I took out this: quote: set my_Conn = Server.CreateObject("ADODB.Connection") my_Conn.Open strConnString
but then I get this error: quote: Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: '' /BG/forums/news.asp, line 16
|
Alfred The Battle Group CREDO
|
Edited by - Alfred on 22 October 2003 23:01:46 |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
|
Topic |
|