vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Replace certain phrase throughout DB?? (https://vborg.vbsupport.ru/showthread.php?t=48788)

007 02-11-2003 09:17 AM

Replace certain phrase throughout DB??
 
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:

Xenon 02-11-2003 10:51 AM

first: replace hack was coded by the sisko :) (search for it :))

second: well, you can write a small script, which get's all usernames out of the posts and creates a user entry in the database, this ist possible :)

007 02-11-2003 11:08 AM

THANKS! I didn't think either of these were possible. As least the first one was. :) That was the easiest hack I have installed to date lol. :) Thanks for pointing that out for me.

Xenon 02-11-2003 11:20 AM

:)
you're welcome :)

the second:
create a file called createusers.php
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?
if(!$userid=$DB_site->query_first("SELECT userid WHERE username='".addslashes($username)."'")) {
  
$DB_site->query("INSERT INTO user (userid,username,password,joindate) VALUES (NULL,'".addslashes($username)."',MD5('".addslashes($username)."'),".time().")");
  
$userid=$DB_site->insert_id();
  
$DB_site->query("INSERT INTO userfield (userid) VALUES ($userid)");

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

}
?>

copy this file into your forum dir and run it, it should create the users :)

007 02-11-2003 11:27 AM

oohh.. !! thought you said it wasn't possible :) cool. looks scary, *backs up db first* ;) i trust you man, but just in case. i'll let you know how it goes :)

007 02-11-2003 11:34 AM

Database error in vBulletin 2.2.9:

Invalid SQL: SELECT userid WHERE username='Array'
mysql error: You have an error in your SQL syntax near 'WHERE username='Array'' at line 1

mysql error number: 1064

hmmm, don't mean to bug you but what does this mean?? thanks again. :) seems like nothing bad happened but it wouldn't let me run that file I just made...

Xenon 02-11-2003 12:14 PM

yeah, sorry, my fault :)

use this:
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?
if(!$userid=$DB_site->query_first("SELECT userid FROM user WHERE username='".addslashes($username[username])."'")) {
  
$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)");
$userid['userid']=$userid;
}
$DB_site->query("UPDATE post SET userid=$userid[userid] WHERE userid=0 AND username=".addslashes($username[username]));

}
?>


007 02-11-2003 12:46 PM

Database error in vBulletin 2.2.9:

Invalid SQL: SELECT userid WHERE username='Dark Master'
mysql error: You have an error in your SQL syntax near 'WHERE username='Dark Master'' at line 1

mysql error number: 1064

any ideas? if this is going to be too much trouble please let me know. :) i'll understand.

Xenon 02-11-2003 01:07 PM

lol, silly me, have forgotten from which table it should take the userid ^^

i've updated my post above :)

007 02-11-2003 07:44 PM

Database error in vBulletin 2.2.9:

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

mysql error number: 1064

:) wahoo! lol hmmm, this looks sort of like the last one I got. any ideas?? thanks.


All times are GMT. The time now is 08:49 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.01927 seconds
  • Memory Usage 1,755KB
  • 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
  • (2)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