vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   in_array(): Wrong datatype for second argument (https://vborg.vbsupport.ru/showthread.php?t=58587)

SmEdD 11-14-2003 02:56 AM

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)) { 


Lesane 11-14-2003 06:01 AM

Try to change:

PHP Code:

$datecut TIMENOW - (24 60 60 1); 

into:

PHP Code:

$datecut TIMENOW() - (24 60 60 1); 


SmEdD 11-14-2003 10:54 AM

Didn't work :(

Xenon 11-14-2003 02:14 PM

before that line:
PHP Code:

while($getnew $DB_site->fetch_array($countnew)) { 

put that code:
PHP Code:

$threadids = array(); 


Dean C 11-14-2003 03:51 PM

if (!in_array($getnew['threadid'], explode(',', $threadids))) {

SmEdD 11-14-2003 08:11 PM

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.

Dean C 11-14-2003 08:45 PM

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 :)

Xenon 11-14-2003 09:34 PM

@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...

KuraFire 11-15-2003 11:11 AM

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 :)

SmEdD 11-15-2003 04:47 PM

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.


All times are GMT. The time now is 02:34 AM.

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.01868 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete