Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Replace certain phrase throughout DB?? Details »»
Replace certain phrase throughout DB??
Version: , by 007 007 is offline
Developer Last Online: Apr 2020 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 02-11-2003 Last Update: Never Installs: 0
 
No support by the author.

Is it possible to replace a :smile: phrase throughout a DB with : ) (without the space obviously)????? I need to know because I imported posts from another (non VB) message board and all the emoticon "calls" are different than what I would like them to be. Is there any way I can replace all these in like 20,000 posts lol???

Also, this was a post only import, so all the usernames come up as userid=0. Are these names actually saved to any place that I could possibly individually add userid's to them?

I'm guessing the answer is no for both of these, but maybe somebody else has done this before? If anyone can offer any suffestions I'd appreciate it. THANKS! :classic:

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 02-11-2003, 07:48 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

k just ran it again (thinking it would work somehow) and it did sort of... but it did this:

Database error in vBulletin 2.2.9:

Invalid SQL: UPDATE post SET userid=5 WHERE userid=0 AND username=Dark Master
mysql error: You have an error in your SQL syntax near 'Master' at line 1

mysql error number: 1064

how do I delete user Id's? that last one seemed to make a user ID 5 which I don't want unless it is an actual user lol. any help? I don't want to just delete the user, but also the id, if that's possible.
Reply With Quote
  #13  
Old 02-11-2003, 07:50 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, shouldn't happen normally, but try this code instead..

PHP Code:
<?php
require('global.php');
$usernames=$DB_site->query("SELECT DISTINCT username FROM post WHERE userid=0");
while (
$username=$DB_site->fetch_array($usernames)) {
//does user exist?
$user=$DB_site->query_first("SELECT userid FROM user WHERE username='".addslashes($username[username])."'");
if(
intval($user[userid])==0) {
  
$DB_site->query("INSERT INTO user (userid,username,password,joindate) VALUES (NULL,'".addslashes($username[username])."',MD5('".addslashes($username[username])."'),".time().")");
  
$userid=$DB_site->insert_id();
  
$DB_site->query("INSERT INTO userfield (userid) VALUES ($userid)");
$DB_site->query("UPDATE post SET userid=".intval($userid)." WHERE userid=0 AND username='".addslashes($username[username])."'");

} else {
$DB_site->query("UPDATE post SET userid=".intval($user[userid])." WHERE userid=0 AND username='".addslashes($username[username])."'");
}

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

sorry, typos ^^

use the updated version now
Reply With Quote
  #15  
Old 02-11-2003, 07:54 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

did you see my second reply? (i edited it right after posting so check if that one applies too) thanks for all this help xenon.
Reply With Quote
  #16  
Old 02-11-2003, 07:59 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the user would work perfectly, no need to delete him
Reply With Quote
  #17  
Old 02-11-2003, 08:03 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well the only thing is when clicking to go to the profile it still goes to this:

.../forums/member.php?action=getinfo&userid=0

so no profile and it also doesn't make the "post started a link." should it? if not then I guess this does work fine. just in case though, if I deleted the user then what querie would I run to update the user Id's and only have the original 4? so the next person who registeres would be 5, and so on? thanks.
Reply With Quote
  #18  
Old 02-11-2003, 08:06 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

when you delete the last user, the autoincrement would go back normally, so the next would be 5 again...

also if not, it's really not needed to have defragmented userid's
Reply With Quote
  #19  
Old 02-11-2003, 08:15 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmmmm, now it's gone haywire on me:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@"domain.com" and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

it was worth a try. thanks. it did work for that one user but then it didn't update the user information on old posts, like when I click the profile it still went to userid=0. i really don't think that this is possible :-/ lol. maybe it's just me and me lack of "knowing what I'm doing" but I guess the old users can just reregister lol. 3 mods already have (one under the same name as their old one) and when I open it to public, I can just leave a note in the registration pages about it. i don't wanna keep you here lol. thanks anyway. the search and replace hack you told me about was awesome. thanks.
Reply With Quote
  #20  
Old 02-11-2003, 08:19 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, the script is working now...
something quite similar has been made here some time before...

just retry it if the error occurs again, you should perhaps ask the host...
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 01:10 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.04522 seconds
  • Memory Usage 2,308KB
  • Queries Executed 26 (?)
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)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)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
  • (9)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete