Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting the Counter Component Working

    I've been trying to get the counter component working about two weeks now and everything has failed. I don't get an error, it just shows a 0 value, infact not even a zero. Nothing,

    Heres my code

    Global.ASA
    Sub Application_OnStart
    Application.Lock
    Application("currentUser") = 0
    Application("allUser") = 0
    Application.UnLock
    End Sub

    Sub Session_OnStart
    Application.Lock
    Application("currentUser") = Application("currentUser") + 1
    Application("allUser") = Application("allUser") +1
    Application.UnLock
    End Sub

    Sub Session_OnEnd
    Application("currentUser") = Application("currentUser") - 1
    End Sub

    Page
    Response.Write(Application("currentUser"))


    Thanks,

    Carl
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Offhand, I don't see any reason why that shouldn't work...

    except the currentuser variable does nothing that the alluser variable doesn't do... so why do you have it in there?...

    Is the global.asa in the same root directory (or parent root directory) as the page that's requesting the application variable?
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I put allusers in there because it wasn't working, plus my book has it in there in the code, so I assume its correct.

    I have the global.asa in the WebRoot directory and the page I access it is in a subfolder.

    Do you happen to have to correct working code for this? I'm getting really frustrated with this

    Carl
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I use application variables every day, so I'm assuming you just overlooked something, or that your book left something out, or that your server isn't set up correctly? OK, I'm going to stop assuming this point and hope you have the code.

    Can you post the code for the global.asa AND the page that's requesting the application variable here?
    Last edited by whammy; 10-04-2002 at 03:11 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I already posted all of the Global.ASA file, so heres my code for the page.

    Code:
    <table cellpadding="0" cellspacing="0" border="0" bgcolor="black" width="95%" align="center" height="1"><tr><td>
    <table width=100% cellspacing="1" height="1">
    <tr>
    <td class="title1">Board Name</td>
    <td class="title1" width="120" align="center">Last Post</td>
    <td class="title1" width="120" align="center">Posts</td>
    </tr>
    <!-- Print Boards Here -->
    <%
    Set conn = Server.CreateObject("ADODB.Connection")
    sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    	"Data Source=\\premfs5\sites\premium10\carlv\database\CBoards\forums.mdb;" & _
    	"Persist Security Info=False"
    conn.Open(sConnection)
    
    sqlCat = "SELECT * FROM Cat ORDER BY theorder"
    Set recCat = conn.Execute(sqlCat)
    
    if Session("loggedin") = "yes" Then
    	sqlUser = "SELECT username,thelevel FROM Users WHERE username='"&Session("CBUsername")&"'"
    	set recUser = conn.Execute(sqlUser)
    	thelevel = recUser("thelevel")
    else
    	thelevel = "1"
    end if	
    
    	Do While Not recCat.EOF
    			if recCat("Hidden") = "y" AND thelevel = "2" Or recCat("Hidden") = "n" Then
    			
    				sqlBoard = "SELECT * FROM Boards WHERE CatID='"&recCat("id")&"' ORDER BY theorder"
    				Set recBoard = conn.Execute(sqlBoard)
    			
    				Response.Write("<tr>")
    				Response.Write("<td class='color1' colspan='4'><b>"&recCat("CatTitle")&"</b></td>")
    				Response.Write("</tr>")
    			
    				Do While Not recBoard.EOF
    				
    						Response.Write("<tr>")
    						Response.Write("<td class='thecolor2'><b><a href='index.asp?page=showboard&boardid="&recBoard("id")&"'>"&recBoard("BoardName")&"</a>")
    						if recBoard("Locked") = "y" Then
    							Response.Write(" - <i>Locked</i>")
    						end if
    						Response.Write("</b><br><i>"&recBoard("BoardDiscription")&"</i></td>")
    						if recBoard("LastPostID") = "0" OR recBoard("LastPostUser") = "" Then
    							Response.Write("<td class='color1' align=center>Never</td>")
    						else
    							Response.Write("<td class='color1' align=center>by, "&recBoard("LastPostUser")&"</td>")
    						end if
    						sqlTP = "SELECT COUNT(*) AS totalpost FROM Topics WHERE BoardID = "&recBoard("id")&""
    						Set recTP = conn.Execute(sqlTP)
    						sqlTR = "SELECT COUNT(*) AS totalreply FROM Replies WHERE BoardID = "&recBoard("id")&""
    						Set recTR = conn.Execute(sqlTR)
    						thetotal = recTP("totalpost") + recTR("totalreply")
    						Response.Write("<td class='thecolor2' align=center>"&thetotal&"</td>")
    						Response.Write("</tr>")
    			
    					recBoard.MoveNext
    				Loop
    			
    			recCat.MoveNext
    			
    			else
    				recCat.MoveNext
    			end if
    	Loop
    
    Set recCat = Nothing
    Set recBoard = Nothing
    %>
    <!-- End Print Boards -->
    <tr>
    
    <td colspan="4" class="color1"><b><a href="index.asp?page=stats">Current Active Users: <%Response.Write(Application("currentUser"))%></a></b></td>
    </tr>
    </table>
    </td></tr></table>
    Carl
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm.. that should work (assuming I didn't miss something)... if I were you I'd make a test .asp page (in the same directory of course), that only contains this line:

    <% = Application("currentUser") %>

    To debug it...

    That would be my first step.

    P.S.

    <% = variable %>

    is a shortcut to

    <% Response.Write(variable) %>
    Last edited by whammy; 10-07-2002 at 01:57 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just a blank page (www.carlsoft.net/test.asp)

    Carl
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I just went there... that proves that your application variable is not being set!

    Now comes the second stage... why?
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #9
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh I just dipise guessing games

    Is that because of the server? I'm using Brinkster.

    Carl
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm... I'm not trying to make guessing games, that's what debugging is all about... it's up to you to figure out by trial and error what's wrong, by making sure that everything that SHOULD work does!

    As for brinkster, I haven't used application variables there, but I'd definitely search their documentation for the global.asa file to see if they have any restrictions on it... I have a site there but it pretty much uses Access 2000 databases or SQL Server...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #11
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Global.ASA files are support by brinkster so no problem there.

    I'll try playing around with the varibles.

    Thanks,
    Carl.
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #12
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    I have used Counter Object with a text file without editing the Global.asa file. I fyou want to see it please visit at

    http://www.bhandaradist.com

    if you do need the code i will.

    Anand
    Have a nice day

    Anand

  • #13
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but I don't see how that shows how many users are online. I can get the page counter working without a problem.

    Thanks though,

    carl
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...

    Looking through your code again, I noticed something... you left out the script tags:

    <script language="vbscript" runat="server">

    </script>

    Which are needed in order for the global.asa file to understand what you're doing.
    Last edited by whammy; 10-06-2002 at 11:29 PM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #15
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But you told me to remove it. I'll put it back.

    It worked!

    Its been three weeks since I've been trying to get this working. Thanks
    Last edited by Carl; 10-06-2002 at 11:35 PM.
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •