Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 10-22-2006, 05:53 PM
josiespencer josiespencer is offline
 
Join Date: Dec 2005
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What is wrong with my query?

I am not a php coder - I am just trying to do a simple update query:

PHP Code:
$db->query_write("UPDATE " TABLE_PREFIX "forum 
SET password="'george' 
$vbulletin->options['dateformat']" WHERE forumid = '757';"); 
Could anyone please help? I am trying to set a password to george20061022.
Reply With Quote
  #2  
Old 10-22-2006, 06:08 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There are a number of errors in that, but first of all it's not going to work even when you correct the syntax as vb does not store passwords directly like that, they are an MD5 hash. Why are you trying to do this ?
Reply With Quote
  #3  
Old 10-22-2006, 06:47 PM
josiespencer josiespencer is offline
 
Join Date: Dec 2005
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin does save the forum passwords like this. I need a password that changes on a specific forum every day. I want to cron it as a task. Could you please offer assistance and not criticism of a feature you obviously have not checked out yourself?
Reply With Quote
  #4  
Old 10-22-2006, 11:07 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice reply

You didn't actually mention this was a forum password in your post and I didn't notice the table name in the SQL - since password questions generally relate to user passwords I mistakenly assumed your request did.

Anyway, you are best splitting this into two lines, something like this.

PHP Code:
$pwdate vbdate('Ymd',TIMENOW);
$db->query_write("UPDATE " .TABLE_PREFIX"forum SET password = george{$pwdate} WHERE forumid = 757"); 
Reply With Quote
  #5  
Old 10-22-2006, 11:35 PM
josiespencer josiespencer is offline
 
Join Date: Dec 2005
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M
Nice reply

You didn't actually mention this was a forum password in your post and I didn't notice the table name in the SQL - since password questions generally relate to user passwords I mistakenly assumed your request did.

Anyway, you are best splitting this into two lines, something like this.

PHP Code:
$pwdate vbdate('Ymd',TIMENOW);
$db->query_write("UPDATE " .TABLE_PREFIX"forum SET password = george{$pwdate} WHERE forumid = 757"); 
Since the update was against the forum table to set the password column, how could you not know it was a forum password?

Anyway, thanks for the help, I will try it out.
Reply With Quote
  #6  
Old 10-22-2006, 11:38 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by josiespencer
Since the update was against the forum table to set the password column, how could you not know it was a forum password?
I believe I mentioned the reason.

Quote:
and I didn't notice the table name in the SQL
:smoke:
Reply With Quote
  #7  
Old 10-22-2006, 11:52 PM
josiespencer josiespencer is offline
 
Join Date: Dec 2005
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, but your code generated an database error:

Reply With Quote
  #8  
Old 10-22-2006, 11:54 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, forgot the single quotes around the password.

PHP Code:
$pwdate vbdate('Ymd',TIMENOW);
$db->query_write("UPDATE " .TABLE_PREFIX"forum SET password = 'george{$pwdate}' WHERE forumid = 757"); 
Reply With Quote
  #9  
Old 10-23-2006, 12:06 AM
josiespencer josiespencer is offline
 
Join Date: Dec 2005
Posts: 100
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent! Thanks! That code plus my code makes a perfect sniplet to change the forum's password and then rebuild the forum so the new password will take effect. Croning it for 12:01 at night will force my forum to have a new password everyday!

PHP Code:
$pwdate vbdate('Ymd',TIMENOW);
$db->query_write("UPDATE " .TABLE_PREFIX"forum SET password = 'george{$pwdate}' WHERE forumid = 757");
build_forum_permissions($forum['757']);
vbflush();
unset(
$forum['757'], $vbulletin->forumcache); 
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:29 PM.


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.04064 seconds
  • Memory Usage 2,249KB
  • 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
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete