Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 How do you link to subs?
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

redbrad0
Advanced Member

USA
3725 Posts

Posted - 20 October 2003 :  23:15:11  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
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
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 21 October 2003 :  00:16:59  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 21 October 2003 :  10:02:27  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
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
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 21 October 2003 :  11:42:58  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 22 October 2003 :  14:06:05  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Your site is down so I could not look at your .txt file but you need to have the config.asp and inc_func_common.asp

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 22 October 2003 :  15:34:08  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 22 October 2003 :  15:37:51  Show Profile
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 ~
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 22 October 2003 :  20:47:41  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Nikkol is correct, with the way we have been trying to show you, you could do..

news.asp?days=365 to show the news for the entire year

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 22 October 2003 :  21:09:18  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 22 October 2003 :  21:14:01  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Well you almost have it, just a bit more work and you will get it.

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 22 October 2003 :  22:18:56  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 22 October 2003 :  22:25:21  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
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
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 22 October 2003 :  22:32:13  Show Profile
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 ~
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 22 October 2003 :  22:57:07  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 22 October 2003 :  23:13:13  Show Profile
just make sure it is included after the connection is opened in inc_header

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.24 seconds. Powered By: Snitz Forums 2000 Version 3.4.07