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 07:48 PM

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.

Xenon 02-11-2003 07:50 PM

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])."'");
}

}
?>


Xenon 02-11-2003 07:54 PM

sorry, typos ^^

use the updated version now :)

007 02-11-2003 07:54 PM

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

Xenon 02-11-2003 07:59 PM

the user would work perfectly, no need to delete him :)

007 02-11-2003 08:03 PM

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.

Xenon 02-11-2003 08:06 PM

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

007 02-11-2003 08:15 PM

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.

Xenon 02-11-2003 08:19 PM

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


All times are GMT. The time now is 09:47 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.01131 seconds
  • Memory Usage 1,745KB
  • 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
  • (1)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
  • (9)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