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 11-14-2003, 02:56 AM
SmEdD's Avatar
SmEdD SmEdD is offline
 
Join Date: Mar 2003
Location: Ontario, Canada
Posts: 381
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default in_array(): Wrong datatype for second argument

Warning: in_array(): Wrong datatype for second argument on line 123

PHP Code:
if ($bbuserinfo['userid']) {
    
$datecut $bbuserinfo['lastvisit'];
} else {
    
$datecut TIMENOW - (24 60 60 1);
}

$countnew $DB_site->query("
        ## GET NEW POSTS / THREADS ##
        SELECT post.postid, post.threadid
        FROM " 
TABLE_PREFIX "post AS post
        WHERE dateline >= 
$datecut
        AND visible = '1'"
);

while(
$getnew $DB_site->fetch_array($countnew)) {
    
$new['posts']++;
    if (!
in_array($getnew['threadid'], $threadids)) {
        
$new['threads']++;
        
$threadids[] = $getnew['threadid'];
    }

Line 123 is

PHP Code:
if (!in_array($getnew['threadid'], $threadids)) { 
Reply With Quote
  #2  
Old 11-14-2003, 06:01 AM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try to change:

PHP Code:
$datecut TIMENOW - (24 60 60 1); 
into:

PHP Code:
$datecut TIMENOW() - (24 60 60 1); 
Reply With Quote
  #3  
Old 11-14-2003, 10:54 AM
SmEdD's Avatar
SmEdD SmEdD is offline
 
Join Date: Mar 2003
Location: Ontario, Canada
Posts: 381
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Didn't work
Reply With Quote
  #4  
Old 11-14-2003, 02:14 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

before that line:
PHP Code:
while($getnew $DB_site->fetch_array($countnew)) { 
put that code:
PHP Code:
$threadids = array(); 
Reply With Quote
  #5  
Old 11-14-2003, 03:51 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if (!in_array($getnew['threadid'], explode(',', $threadids))) {
Reply With Quote
  #6  
Old 11-14-2003, 08:11 PM
SmEdD's Avatar
SmEdD SmEdD is offline
 
Join Date: Mar 2003
Location: Ontario, Canada
Posts: 381
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm . . . still don't work, I donno how it didn't since you are all amazing coders . . . Is there any other way of redoing the in_array. I also tryed a combination of all of thoes lines but nothing seems to want to work.
Reply With Quote
  #7  
Old 11-14-2003, 08:45 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm assuming the contents of $threadids is a list of thread id's. If so the code above should work ^^ I use it all the time with global admin cp options
Reply With Quote
  #8  
Old 11-14-2003, 09:34 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@Dean: you should look at the code before trying to help:

PHP Code:
$threadids[] = $getnew['threadid']; 
you can clearly see it's not a list but an array


but it hasn't been intialised in the first loop.
that's why i thought the initialisation of it in front of the loop should do it...
Reply With Quote
  #9  
Old 11-15-2003, 11:11 AM
KuraFire's Avatar
KuraFire KuraFire is offline
 
Join Date: Oct 2001
Location: inside vB3's .php
Posts: 1,245
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Putting

PHP Code:
$threadids = array(); 
all the way at the top of the code segment you pasted in the first post should do it.


HOWEVER!

This code gives you the exact same results and is cleaner and simpler:

PHP Code:
$datecut = ($bbuserinfo['userid'] != 0) ? $bbuserinfo['lastvisit'] : TIMENOW - (24 60 60 1);
   
   
$new $DB_site->query_first("SELECT COUNT(post.postid) as posts, COUNT(DISTINCT(post.threadid)) as threads
   FROM " 
TABLE_PREFIX "post AS post
   WHERE dateline >= 
$datecut
   AND visible = '1'"
); 
Depending on the amount of data, it can be a lot faster (with lots of threads and posts) to a little bit slower (with few threads and posts on a big board nonetheless).

You may want to do some benchmarking on your own board to see which method is faster on your forums. Keep in mind that the results (speed-wise) will depend solely on how many new threads / posts there actually are in the result.

Good luck
Reply With Quote
  #10  
Old 11-15-2003, 04:47 PM
SmEdD's Avatar
SmEdD SmEdD is offline
 
Join Date: Mar 2003
Location: Ontario, Canada
Posts: 381
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

lol I am so stupid . . . The reason the other wern't working was cause I was uploading to the wrong site, but I wasn't paying attection when I clicked connect so that is why.

But ya it works now, so thanks.
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 07:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06930 seconds
  • Memory Usage 2,276KB
  • Queries Executed 11 (?)
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
  • (9)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete