Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2002, 04:57 AM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Retrieving lastvisit, should be easy...

Ok this is my code

PHP Code:
$getuser=$DB_site->query("SELECT * FROM user WHERE userid=$bbuserinfo[userid]");

while (
$user=$DB_site->fetch_array($getuser)) {
$username=$user[username];
$userlastvisit=$user['lastvisit'];
$newposts="<a href=\"search.php?s=$session[sessionhash]&action=getnew\">View New Posts</a>";
$logout="<smallfont><a href=\"member.php?s=$session[sessionhash]&action=logout\">Log Out</a>";
$markallread="<a href=\"member.php?s=$session[sessionhash]&action=markread\">Mark All Forums Read</a>";
}

eval(
"\$welcometext .= \"".gettemplate('home_usercp')."\";"); 
But everytime I call $userlastvisit it says "1018586613" I have tried $user[lastvisit], $user[lastvisitdate], $user['lastvisit'], and $user['lastvisitdate']. I'm probably making this harder than it should be, but help please. gre:
Reply With Quote
  #2  
Old 04-12-2002, 04:03 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First of all, use the query_first() method instead of query() and then fetch_array(), since you are only getting one row of data.

Anyway, what you get (that long number) is in Unix Timestamp, and needs to be converted. Use:
Code:
$userlastvisit = vbdate("FORMAT", $user['lastvisit']);
FORMAT is the format of the date / time, see the manual entry for date() for more info.
Reply With Quote
  #3  
Old 04-13-2002, 01:13 AM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanx FireFly, that was MUCH easier than what I thought it would be. :bandit:

But about the query_first, if I use that I get an error in db_mysql about a bad argument, so I had to just use query.
Reply With Quote
  #4  
Old 04-13-2002, 06:00 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you use query_first() you don't need fetch_array(), because it does that internally.

So instead of:
Code:
$getuser=$DB_site->query("SELECT * FROM user WHERE userid=$bbuserinfo[userid]");

while ($user=$DB_site->fetch_array($getuser)) {
$username=$user[username];
$userlastvisit=$user['lastvisit'];
$newposts="<a href=\"search.php?s=$session[sessionhash]&action=getnew\">View New Posts</a>";
$logout="<smallfont><a href=\"member.php?s=$session[sessionhash]&action=logout\">Log Out</a>";
$markallread="<a href=\"member.php?s=$session[sessionhash]&action=markread\">Mark All Forums Read</a>";
}
You just use this:
Code:
$user=$DB_site->query_first("SELECT * FROM user WHERE userid=$bbuserinfo[userid]");

$username=$user[username];
$userlastvisit=$user['lastvisit'];
$newposts="<a href=\"search.php?s=$session[sessionhash]&action=getnew\">View New Posts</a>";
$logout="<smallfont><a href=\"member.php?s=$session[sessionhash]&action=logout\">Log Out</a>";
$markallread="<a href=\"member.php?s=$session[sessionhash]&action=markread\">Mark All Forums Read</a>";
Reply With Quote
  #5  
Old 04-13-2002, 05:53 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh ok I got it now, sorry I'm still trying to learn all this coding.
Reply With Quote
  #6  
Old 04-15-2002, 11:26 AM
jjj0923's Avatar
jjj0923 jjj0923 is offline
 
Join Date: Mar 2002
Location: Maryland
Posts: 146
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Firefly - what a timely post.

Thanks for this information.

While we're on the subject, I was working over the weekend trying something along the same lines.

I have Photopost installed along with vbulletin and I want to pop-up a little javascript message or display a blinking "photo gallery" graphic if there have been new photos posted in the gallery since the users last visit.

The problem I was running into was selecting the photopost db in index.php. It would appear to get selected properly (since servername, username & password) are the same, but then I went to select data from the photpost db, I would get a message returned a string that said something like "Resource ID 27".

I'm fairly confident the select_db was working ok becuase if I did not reselect the Vbulletin db at the end of my code, vb would throw errors.

any ideas????

thanks if advance Firefly!

- jeff
Reply With Quote
  #7  
Old 04-15-2002, 11:34 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$result = mysql_query_db(...);
$result isn't what you are looking for, you first need to fetch the row:
Code:
$row = mysql_fetch_array($result);
And then use $result['fieldName'].
Reply With Quote
  #8  
Old 04-15-2002, 11:46 AM
jjj0923's Avatar
jjj0923 jjj0923 is offline
 
Join Date: Mar 2002
Location: Maryland
Posts: 146
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

cool - thanks!

now where do you want me to send contributions for that condo????

- jeff
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:33 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03867 seconds
  • Memory Usage 2,241KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete