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 08-12-2004, 02:26 AM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Automatically closing threads

I Currently am working with this PHP Script to close threads older than a year, but I can't seem to get it to work, on my command line, I can type
php closethreads.php and it goes on w/o error, but the threads don't lock.. I constructed this with a little bit of other codes i've found on here.. Any help is greatly appreciated!

PHP Code:
$DB_site->query("UPDATE thread
                 SET open = 0
                 WHERE dateline < "
.(TIMENOW - (60 60 24 364))."
                  AND forumid IN (3,4,5)
"
);
?> 
Reply With Quote
  #2  
Old 08-12-2004, 03:08 AM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm...

I assume you've included global.php etc?

can you post the entire script, maybe it's something earlier in it because that query looks great to me.

If your admin set error reporting to none by default then it wouldn't show any errors. My admin did that once...worst developing environment ever.
Reply With Quote
  #3  
Old 08-12-2004, 03:13 AM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OOpsie, Thanks for the reply! I thought I had copied the whole script, but guess not, lol.. I run my own server, so I can luckily configure everything needed for debugging. I should mention this is for vB2.3.5 - Here's what my entire script looks like.. :classic:

PHP Code:
<?php
require("./global.php");
$DB_site->query("UPDATE thread
                 SET open = 0
                 WHERE dateline < "
.(TIMENOW - (60 60 24 364))."
                     AND forumid IN (3,4,5)
"
);
?>
Reply With Quote
  #4  
Old 08-12-2004, 03:20 AM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm... maybe global.php won't let you use it outside of a browser... try this instead.


PHP Code:
<?php

$db 
mysql_connect($db_server$db_user$db_pass) or 
        die(
"Could not connect to database with error (".mysql_error().")");

$db_sel mysql_select_db($db_name$db) or 
        die(
"Could not select database $db_name with error (".mysql_error().")");        
        
mysql_query("UPDATE thread SET open = 0 WHERE dateline < ".(TIMENOW - (60 60 24 364))." AND forumid IN (3,4,5)"$db);        
?>
(replacing the necessary variables with your database info of course )
Reply With Quote
  #5  
Old 08-12-2004, 03:48 AM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm.. Still no go That code is definately a lot better looking though. It's definitely got me baffled, lol.. I really appreciate your help!! I'm learning the way around MySQL pretty good, but not quite well enough, lol

PHP Code:

<?php

$db 
mysql_connect('localhost''un''pw') or
        die(
"Could not connect to database with error (".mysql_error().")");

$db_sel mysql_select_db('dbname'$db) or
        die(
"Could not select database $db_name with error (".mysql_error().")");

mysql_query("UPDATE thread SET open = 0 WHERE dateline < ".(TIMENOW - (60 60 24 364))." AND forumid IN (3,4,5)"$db);
?>
There is still no output below.. hmm
Code:
[root@ball vb]# php closethreads.php

[root@ball vb]#
Reply With Quote
  #6  
Old 08-12-2004, 03:51 AM
Natch's Avatar
Natch Natch is offline
 
Join Date: Nov 2002
Location: Australia
Posts: 851
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There will be no output unless you echo something out ...
Reply With Quote
  #7  
Old 08-12-2004, 04:32 AM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah, there shouldn't be output with that script, though it should update your database.

at the end of it if you want confirmation then add the line. Or whatever you want it to say
Code:
echo "Script Completed";
Reply With Quote
  #8  
Old 08-12-2004, 04:46 AM
hurrican hurrican is offline
 
Join Date: Feb 2004
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did do that just to confirm, but for some weird reason, the threads still don't get closed. I'm baffled, lol. If I go look in phpMySQLadmin the real old threads still all show 1 (open) so I did a search for 0, and they were threads that were already closed.. Any possible suggestions as to why nothing will update??

thanks again, i'll check back in the morning!
Reply With Quote
  #9  
Old 08-12-2004, 04:55 AM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

whooops...

here try this instead

PHP Code:
<?php

$db 
mysql_connect('localhost''un''pw') or
        die(
"Could not connect to database with error (".mysql_error().")");

$db_sel mysql_select_db('dbname'$db) or
        die(
"Could not select database $db_name with error (".mysql_error().")");

mysql_query("UPDATE thread SET open = 0 WHERE dateline < ".(time() - (60 60 24 364))." AND forumid IN (3,4,5)"$db);
?>
Reply With Quote
  #10  
Old 08-12-2004, 08:06 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you're using vB3 take a look at one of the files in the includes/cron directory. Put your script you have at the top in a new file in that directory. And add it as a scheduled task
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 02:09 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.04273 seconds
  • Memory Usage 2,277KB
  • 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
  • (2)bbcode_code
  • (5)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