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)
 Need Help please!
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Bandit
Starting Member

15 Posts

Posted - 10 August 2001 :  09:53:10  Show Profile
Hi @ all!

I have a Problem, im programming a forum for myself becose all Forums i found are not that what im looking for.

Here is my Problem: i want to Display information about the "last-login-date" of a member and i dont really think i can solve it self. Im thinking now about 10 hours and still nothing..

i have 'members' table in my access DB in this table is a field 'lastvisit_date', there the data must be stored but all i got for now is this code:

<%
if Request.Cookies("tdn")("login") = "yes" then
userid = Request.Cookies("tdn")("userid")

SQL = "UPDATE members SET "
SQL = SQL & "lastvisit_date='" & Session("Start") & "'"
SQL = SQL & "WHERE id=" & userid
Conn.Execute (SQL)
Sql = "SELECT lastvisit_date from members where id=" & userid
set rs = Conn.Execute (Sql)
lastheredate=rs("lastvisit_date")
rs.close
end if

response.write ("Your last Visit was on:" & lastvisit_date & "")
%>


And it works not so how i want. Any Time i open a new window the date in members.lastvisit_date is overwriten..

Sorry for my english its not so good..


Can u guys help me to solve this problem?

thx
Michael

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 10 August 2001 :  10:16:00  Show Profile  Visit Kat's Homepage
quote:


<%
if Request.Cookies("tdn")("login") = "yes" then
userid = Request.Cookies("tdn")("userid")
if session("lastheredate") = "" then
SQL = "UPDATE members SET "
SQL = SQL & "lastvisit_date='" & Session("Start") & "'"
SQL = SQL & "WHERE id=" & userid
Conn.Execute (SQL)
Sql = "SELECT lastvisit_date from members where id=" & userid
set rs = Conn.Execute (Sql)
Session("lastheredate")=rs("lastvisit_date")

rs.close
end if
end if
response.write ("Your last Visit was on:" & Session("lastheredate"))

%>



Try adding what I have added to you code above. I haven't tested it but it should do what you want. Writing to the session variable makes this date value available throughout your forum. without further calls to the database. The way I have suggested, it will only get set once during a visit.


KatsKorner
Go to Top of Page

Bandit
Starting Member

15 Posts

Posted - 10 August 2001 :  10:36:36  Show Profile
its still the same but it was a good idea!

and i was so happy before i tested argh..
maybe some other idea?

thx for now

Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 10 August 2001 :  12:13:17  Show Profile  Visit Kat's Homepage
I don't understand. That code changed the logic so it shouldn't be the same. Can you post the code again?

KatsKorner
Go to Top of Page

Bandit
Starting Member

15 Posts

Posted - 10 August 2001 :  12:26:31  Show Profile
yes here is the code again, i just changed names of the vars:


if Request.Cookies("tdnbb")("login") = "ja" then
userid = Request.Cookies("tdnbb")("userid")

if session("lastheredate") = "" then

SQL = "UPDATE members SET "
SQL = SQL & "last_date='" & Session("Start") & "'"
SQL = SQL & "WHERE id=" & userid
Conn.Execute (SQL)

Sql = "SELECT last_date from members where id=" & userid
set rs = Conn.Execute (Sql)

Session("lastheredate")=rs("last_date")

lastheredate=rs("last_date")
end if

end if



With this code when i enter my forum the last visit date = date()
Everytime i refresh


Go to Top of Page

Bandit
Starting Member

15 Posts

Posted - 10 August 2001 :  12:54:23  Show Profile
i figured it out, everything seems to work now with this code!


if Request.Cookies("tdnbb")("login") = "ja" then
userid = Request.Cookies("tdnbb")("userid")

if session("lastheredate") = "" then

Sql = "SELECT last_date from members where id=" & userid
set rs = Conn.Execute (Sql)
lastheredate=rs("last_date")
Session("lastheredate")=rs("last_date")

SQL = "UPDATE members SET "
SQL = SQL & "last_date='" & Session("Start") & "'"
SQL = SQL & "WHERE id=" & userid
Conn.Execute (SQL)

end if
end if



Thanx a LOT! for helping!
**** i have spend 15 hours for this crap

see you!

Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 13 August 2001 :  05:07:59  Show Profile  Visit Kat's Homepage
Glad you sorted it - looks like the logic was right but you needed to apply the update at a different point.

Next time, you will sort it quicker than 15 hours. It does get easier, but some problems can be a nusiance!

KatsKorner
Go to Top of Page
  Previous Topic Topic Next Topic  
 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.31 seconds. Powered By: Snitz Forums 2000 Version 3.4.07