Author |
Topic  |
|
dikonstrukt
Starting Member
13 Posts |
Posted - 09 December 2001 : 12:32:58
|
Hi, I to add my Total Members to my home page (different than the forums page). I've tried to take the code from the statistics.asp file (below) but no variation of it works for me.
Can someone please help me figure this one out? I've tried what seems like every way, and I'm sure it's something simple I'm missing, but it's not simple to me...
Thanks! Dikon
<% function WriteStatistics() Dim Member_Count set rs = Server.CreateObject("ADODB.Recordset")
'## Forum_SQL - Get Active membercount from DB strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS WHERE M_POSTS > 0 AND M_STATUS=1"
set rs = my_Conn.Execute(strSql) if not rs.EOF then Member_Count = rs("U_COUNT") else Member_Count = 0 end if
rs.close set rs = nothing %>
<tr> <td align="right">Total members: </td>
<td align="left"> <% if Member_Count = 0 then response.write Member_Count
else if Member_Count > 0 then Response.Write Member_Count end if %>
<% End Function %>
|
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 09 December 2001 : 12:49:30
|
quote: if Member_Count = 0 then response.write Member_Count
else if Member_Count > 0 then Response.Write Member_Count
This is confusing, it does the same thing either way. The admin user cannot be removed without directly editing the database, so you might just want to replace this whole block with
Response.Write Member_Count
Nathan Bales - Romans 15:13 ------------------------------- Test Site | Mod Resource |
 |
|
dikonstrukt
Starting Member
13 Posts |
Posted - 09 December 2001 : 13:05:35
|
Hi, Nathan
Thanks for the response! I tried what you suggested, and got halfway there ... the first <td> tag shows now Total Members:
But, there is no sign of the number itself. There are currently 7 members in the database. Any other ideas?
Thanks again, Dikon
PS: You can see this in (non-)operation at http://www.egoplanet.org
|
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 09 December 2001 : 13:20:48
|
You open a table row, open a table cell, close a table cell, and open a 2nd table cell
You never close 2nd table cell, or the table row. This might be causeing part of the problem.
Could you provide a link to the page?
Nathan Bales - Romans 15:13 ------------------------------- Test Site | Mod Resource |
 |
|
dikonstrukt
Starting Member
13 Posts |
|
Roland
Advanced Member
    
Netherlands
9335 Posts |
Posted - 09 December 2001 : 13:55:16
|
quote:
<% function WriteStatistics() Dim Member_Count set rs = Server.CreateObject("ADODB.Recordset")
'## Forum_SQL - Get Active membercount from DB strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS WHERE M_POSTS > 0 AND M_STATUS=1"
set rs = my_Conn.Execute(strSql) if not rs.EOF then Member_Count = rs("U_COUNT") else Member_Count = 0 end if
rs.close set rs = nothing %>
<tr> <td align="right">Total members: </td>
<td align="left"> <% if Member_Count = 0 then response.write Member_Count
else if Member_Count > 0 then Response.Write Member_Count end if %> </td> </tr> <% End Function %>
quote:
You open a table row, open a table cell, close a table cell, and open a 2nd table cell
You never close 2nd table cell, or the table row. This might be causeing part of the problem.
I've shown the missing code in red in the first quote.
quote: Yeah, that's beyond my knowledge of ASP right now 
That's not ASP, creating a table is basic HTML.
Roland |
 |
|
dikonstrukt
Starting Member
13 Posts |
Posted - 09 December 2001 : 14:19:27
|
Hi, Frutzle...
Those end tags weren't missing, I just didn't include them in the post. I know HTML very well. Certainly enough to check for missing table tags 
Any ideas how to solve the problem?
Thanks!
Dikon
|
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 09 December 2001 : 14:30:02
|
You also need to set the connection object. Have you included the config.asp and inc_top.asp in your Homepage. How are you connecting to the database to pull the info from members table?
 GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
 |
|
dikonstrukt
Starting Member
13 Posts |
Posted - 09 December 2001 : 14:38:07
|
Hi, GauravBhabu
Yes, I have the following include files in the home page:
<!--#INCLUDE FILE="config.asp" --> <!--#INCLUDE FILE="inc_functions.asp" --> <!--#INCLUDE FILE="inc_top.asp" -->
As far how I am connecting to the database, to be honest, I don't really know. I just copied the code I thought looked right (yeah...probably isn't) from the statistics.asp file.
I'm probably totally mistaken, but I thought that the following lines created the connection:
set rs = Server.CreateObject("ADODB.Recordset")
'## Forum_SQL - Get Active membercount from DB strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS WHERE M_POSTS > 0 AND M_STATUS=1"
set rs = my_Conn.Execute(strSql)
I must be doing this wrong, but I don't know what. By the code I have in my homepage is above in my first post.
|
 |
|
dikonstrukt
Starting Member
13 Posts |
Posted - 09 December 2001 : 14:45:29
|
Sorry, I realized I didn't include all of the code, and that may be helpful to solving the problem. Basically it's a combination of the Who's Online Script and what I posted before from the statistics.asp file.
I apologize for the length.... Thanks for all of the help so far!
Dikon
*********************
<% ' WHOS ONLINE SCRIPT
rqForum = Request("FORUM_ID") if rqForum ="" then rqForum = 0
' ****************************************************** ' ADD HERE WHAT YOU WANT THE PREFIX OF YOUR COOKIE TO BE ' it will either be 'strCookieURL' or 'strUniqueID' strTempCookieType = strUniqueID ' ******************************************************
Function OnlineSQLencode(byVal strPass) If not isNull(strPass) and strPass <> "" Then strPass = Replace(strPass, "%", "'%'") strPass = Replace(strPass, "'", "''") strPass = Replace(strPass, "|", "'|'") OnlineSQLencode = strPass End If End Function
Function OnlineSQLdecode(byVal strPass) If not isNull(strPass) and strPass <> "" Then strPass = Replace(strPass, "'%'", "%") strPass = Replace(strPass, "''", "'") strPass = Replace(strPass, "'|'", "|") OnlineSQLdecode = strPass End If End Function
' LETS GET WHAT PAGE THEY ARE ON strOnlinePathInfo = Request.ServerVariables("Path_Info") strOnlineQueryString = Request.QueryString
' TRY AND FIND OUT WHAT PAGE THEY ARE ON If lcase(Right(strOnlinePathInfo, 9)) = "forum.asp" Then strOnlineLocation = "Viewing Forum page" ElseIf lcase(Right(strOnlinePathInfo, 11)) = "default.asp" Then strOnlineLocation = "<a href=""default.asp"">Home</a>" ElseIf lcase(Right(strOnlinePathInfo, 9)) = "topic.asp" Then strOnlineLocation = "Viewing Message" ElseIf lcase(Right(strOnlinePathInfo, 8)) = "post.asp" Then If Request.QueryString("method") = "Reply" Then if chkForumAccess(rqForum,getNewMemberNumber()) then strOnlineLocation = "Replying To Message ' <a href=""topic.asp?" & strOnlineQueryString & """>" & formatStr(ChkString(Request.QueryString("Topic_Title"),"display")) & "</a> '" else strOnlineLocation = "Private Forum" end if ElseIf Request.QueryString("method") = "Topic" Then if chkForumAccess(rqForum,getNewMemberNumber()) then strOnlineLocation = "Posting New Topic in ' <a href=""forum.asp?" & strOnlineQueryString & """>" & formatStr(ChkString(Request.QueryString("Topic_Title"),"display")) & "</a> '" else strOnlineLocation = "Private Forum 4" end if Else strOnlineLocation = "Unknown" End If ElseIf lcase(Right(strOnlinePathInfo, 10)) = "active.asp" Then strOnlineLocation = "<a href=""active.asp"">Active Topics</a>" ElseIf lcase(Right(strOnlinePathInfo, 10)) = "events.asp" Then strOnlineLocation = "<a href=""events.asp"">Events Calender</a>" ElseIf lcase(Right(strOnlinePathInfo, 11)) = "members.asp" Then strOnlineLocation = "<a href=""members.asp"">Members</a>" ElseIf lcase(Right(strOnlinePathInfo, 10)) = "search.asp" Then strOnlineLocation = "<a href=""search.asp"">Search</a>" ElseIf lcase(Right(strOnlinePathInfo, 7)) = "faq.asp" Then strOnlineLocation = "<a href=""faq.asp"">FAQ</a>" ElseIf lcase(Right(strOnlinePathInfo, 15)) = "pop_profile.asp" Then If Request.QueryString("mode") = "Display" Then strOnlineLocation = "<a href=""pop_profile.asp?" & strOnlineQueryString & """>Members Profile</a> '" Else strOnlineLocation = "Profile" End If ElseIf lcase(Right(strOnlinePathInfo, 11)) = "pm_view.asp" Then strOnlineLocation = "<a href=""pm_view.asp"">Private Message Inbox</a>" ElseIf lcase(Right(strOnlinePathInfo, 14)) = "pm_options.asp" Then strOnlineLocation = "<a href=""pm_view.asp"">Private Messages Options</a>" ElseIf lcase(Right(strOnlinePathInfo, 15)) = "privatesend.asp" Then strOnlineLocation = "<a href=""privatesend.asp"">Sending Private Message</a>" ElseIf lcase(Right(strOnlinePathInfo, 16)) = "active_users.asp" Then strOnlineLocation = "<a href=""active_users.asp"">This Page</a>" ElseIf InStr(strOnlinePathInfo,"Forum") = 0 Then strOnlineLocation = "<a href=""default.asp"">Not in Forum</a>" Else strOnlineLocation = "Unknown Page" End If
' FIND OUT IF THEY ARE A GUEST, OR A USER if strDBNTusername = "" then strOnlineUser = "Guest" else strOnlineUser = strDBNTusername end if
strOnlineUserIP = remoteIP()
' LETS ENCODE THIS INFO strOnlineUser = OnlineSQLencode(strOnlineUser) strOnlineLocation = OnlineSQLencode(strOnlineLocation)
' SET WHEN TO TIMEOUT THE USER ' DO THIS IN SECONDS strOnlineDate = DateToStr(Date) strOnlineCheckInTime = DateToStr(strForumTimeAdjust)
strOnlineTimedOut = strOnlineCheckInTime -660 SQL = "DELETE FROM " & strTablePrefix & "ONLINE WHERE LastCheckedIn < '" & strOnlineTimedOut & "'" SQL = SQL & " AND DateCreated < '" & strOnlineDate & "'" my_Conn.Execute SQL SQL = "UPDATE " & strTablePrefix & "ONLINE SET VISITS=1,DateCreated='" & strOnlineDAte & "' WHERE DateCreated <> '" & strOnlineDate & "'" my_conn.execute SQL
strSql = "SELECT " & strTablePrefix & "ONLINE.UserID, " & strTablePrefix & "ONLINE.UserIP, " & strTablePrefix & "ONLINE.LastCheckedIn,CheckedIn" strSql = strSql & " FROM " & strTablePrefix & "ONLINE " strSql = strSql & " WHERE " & strTablePrefix & "ONLINE.UserIP='" & strOnlineUserIP & "' AND " & strTablePrefix & "ONLINE.UserID='" & strOnlineUser & "'"
set rsWho = my_Conn.Execute (strSql)
if rsWho.eof or rsWho.bof then ' THEY ARE A NEW USER SO INSERT THERE USERNAME on error resume next Set objRS2 = Server.CreateObject("ADODB.Recordset") strSQL = "INSERT INTO " & strTablePrefix & "ONLINE (UserID,UserIP,DateCreated,CheckedIn,LastCheckedIn,M_BROWSE,VISITS) VALUES ('" strSql = strSQL & strOnlineUser & "','" & strOnlineUserIP & "','" & strOnlineDate & "','" & strOnlineCheckInTime & "','" & strOnlineCheckInTime & "','" & strOnlineLocation & "',1)" my_Conn.Execute (strSql) if err.number <> 0 then response.write err.number & "|" & err.description else ' LETS UPDATE THE TABLE SO IT SHOWS THERE LAST ACTIVE VISIT if rsWho("CheckedIn") = "" then strSql = "UPDATE " & strTablePrefix & "ONLINE SET CheckedIn='" & strOnlineCheckInTime & "', M_BROWSE='" & strOnlineLocation & "' , LastCheckedIn='" & strOnlineCheckInTime & "', VISITS=VISITS+1 WHERE UserID='" & strOnlineUser & "' AND " & strTablePrefix & "ONLINE.UserIP='" & strOnlineUserIP & "'" else strSql = "UPDATE " & strTablePrefix & "ONLINE SET M_BROWSE='" & strOnlineLocation & "' , LastCheckedIn='" & strOnlineCheckInTime & "' WHERE UserID='" & strOnlineUser & "' AND " & strTablePrefix & "ONLINE.UserIP='" & strOnlineUserIP & "'" end if
my_Conn.Execute (strSql) end if
' LETS RESET ALL INACTIVE USERS strOnlineTimedOut = strOnlineCheckInTime -660 'time out the user after 11 minutes ( 660 seconds ) SQL = "UPDATE " & strTablePrefix & "ONLINE SET CheckedIn = '' WHERE LastCheckedIn < '" & strOnlineTimedOut & "'" SQL = SQL & " AND UserID <> '" & strOnlineUser & "'"
my_Conn.Execute SQL
set rsOnline = Server.CreateObject("ADODB.Recordset")
if strDBType = "access" then strSqL = "SELECT count(UserID) AS [onlinecount] " else strSqL = "SELECT count(UserID) AS onlinecount " end if
strSql = strSql & "FROM " & strTablePrefix & "ONLINE " Set rsOnline = my_Conn.Execute(strSql) onlinecount = rsOnline("onlinecount") strOnlineUsersCount = rsOnline("onlinecount")
' Get Guest count for display on Default.asp set rsGuests = Server.CreateObject("ADODB.Recordset") if strDBType = "access" then strSqL = "SELECT count(UserID) AS [Guests] " else strSqL = "SELECT count(UserID) AS Guests " end if strSql = strSql & "FROM " & strTablePrefix & "ONLINE " strSql = strSql & " WHERE Right(UserID, 5) = 'Guest' AND LastCheckedIn > '" & strOnlineTimedOut & "'"
Set rsGuests = my_Conn.Execute(strSql) Guests = rsGuests("Guests") strOnlineGuestsCount = rsGuests("Guests")
' Get Member count for display on Default.asp set rsGuests = Server.CreateObject("ADODB.Recordset") if strDBType = "access" then strSqL = "SELECT count(UserID) AS [Members] " else strSqL = "SELECT count(UserID) AS Members " end if strSql = strSql & "FROM " & strTablePrefix & "ONLINE " strSql = strSql & " WHERE Right(UserID, 5) <> 'Guest' AND LastCheckedIn > '" & strOnlineTimedOut & "'"
Set rsMembers = my_Conn.Execute(strSql) Members = rsMembers("Members") strOnlineMembersCount = rsMembers("Members")
if strDBType = "access" then strSqL = "SELECT count(UserID) AS [Members] " else strSqL = "SELECT count(UserID) AS Members " end if strSql = strSql & "FROM " & strTablePrefix & "ONLINE " strSql = strSql & " WHERE Right(UserID, 5) <> 'Guest' "
Set rsMembers = my_Conn.Execute(strSql) Members = rsMembers("Members") strVisitors = rsMembers("Members") ' END WHOS ONLINE SCRIPT %>
<% function WriteStatistics() Dim Member_Count set rs = Server.CreateObject("ADODB.Recordset")
'## Forum_SQL - Get Active membercount from DB strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS WHERE M_POSTS > 0 AND M_STATUS=1"
set rs = my_Conn.Execute(strSql) if not rs.EOF then Member_Count = rs("U_COUNT") else Member_Count = 0 end if rs.close set rs = nothing end function %>
|
 |
|
dikonstrukt
Starting Member
13 Posts |
Posted - 09 December 2001 : 22:12:27
|
Well, I *finally* figured it out...
Now I have a much better understanding of what the SQL is doing, so I suppose the gnashing of teeth was worthwhile. But for those less masochistic, here is the code:
<% set rsMembers = Server.CreateObject("ADODB.Recordset") if strDBType = "access" then strSqL = "SELECT count(MEMBER_ID) AS [Members] " else strSqL = "SELECT count(MEMBER_ID) AS Members " end if strSql = strSql & "FROM " & strTablePrefix & "MEMBERS " strSql = strSql & " WHERE M_STATUS=1 " set rsMembers = my_Conn.Execute(strSql) Total = rsMembers("Members") strTotalMembers = rsMembers("Members") Response.Write strTotalMembers %>
Hope someone else gets to enjoy it!
Dikon
|
 |
|
Nathan
Help Moderator
    
USA
7664 Posts |
Posted - 09 December 2001 : 22:34:13
|
Glad to hear you figgured it out 
Nathan Bales - Romans 15:13 ------------------------------- Test Site | Mod Resource |
 |
|
|
Topic  |
|
|
|