Welcome to Geeklog, Anonymous Monday, December 30 2024 @ 11:50 am EST

Geeklog Forums

Search and Replace Text and/or partial strings in Geeklog DB


Status: offline

vitaly

Forum User
Newbie
Registered: 01/21/05
Posts: 5
Hello all,

I have a small problem where all my urls have chnaged for almost everything I posted... meaning that my url was like http://toolnetservices.com/...
and now I have to specifiy http://bf.toolnetservices.com/...
how do I update every table in geeklog to reflect just this small change
without
1) erasing/overwriting what I have in there now... just updating... or string repalcement
2) manually changing every post, forum, etc...

so I guess I just need to know the piece of sql code or phpMyAdmin way to do this operation...

Thanks.
Vitaly Bokser
BOKSERFILMS
www.bokserfilms.com
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
My suggestion for the FAQ still stands.
 Quote

Status: offline

vitaly

Forum User
Newbie
Registered: 01/21/05
Posts: 5
Quote by LWC: My suggestion for the FAQ still stands.

I guess thats an answer, but not the one I was seeking...
and yes I did search the website and found nothing that related to my particular question... maybe next you can give search advise or a real link??? up to u.

Thanks.
Vitaly Bokser
BOKSERFILMS
www.bokserfilms.com
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
I can't read the link given above but I usually download the MySQL as a .sql file within PHP MyAdmin. If you unpack it you will see it is a text file! So take a plain text editor and search and replace the code, save it and upload it again. Don't forget a security copy!
 Quote

Status: offline

vitaly

Forum User
Newbie
Registered: 01/21/05
Posts: 5
that is a simple yet elegant answer, and I thank you my good man!
Vitaly Bokser
BOKSERFILMS
www.bokserfilms.com
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Pleasure! Laughing I suppose the link above should go to "Migrating a Geeklog site" http://www.geeklog.net/faqman/index.php?op=view&t=37

This sentence "...so you'll have to edit those image URLs in the database directly (using phpMyAdmin)..." is NOT the only solution. As I said one can edit the text file offline.This is even better, because you will have to make many, many, many, many ,many more URL changes if you have the stats plugin installed etc. Wink

Maybe Dirk can add this hint in the FAQ.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
you could do it the easy way as above, but let's be dangerous--just for fun.
first backup your db cuz I don't want to be responsible for loss.
then try and run this.
Text Formatted Code

<?php

// run this from your public_html where your lib-common.php resides.
require_once('lib-common.php');

// $_TABLES corresponds to all your Geeklog tables.
// It should also take care of the forum plug-in.
// Some plug-ins have their tables specified otherwise.  See their config.php's for more info.

foreach ($_TABLES as $table){
    $query = DB_query("SELECT * FROM $table");
    $i = 0;
    while ($i < DB_numFields($query)){
        $fieldname = DB_fieldname($query,$i);
        DB_query("UPDATE $table SET $fieldname=REPLACE($fieldname,'http://toolnetservices.com','http://bf.toolnetservices.com')");
    }
}
echo 'done';
?>

 
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
...and now, after having read the thread, I guess my solution is what LWC was talking about.
 Quote

vitaly

Anonymous
Quote by machinari: you could do it the easy way as above, but let's be dangerous--just for fun.
first backup your db cuz I don't want to be responsible for loss.
then try and run this.
Text Formatted Code

<?php

// run this from your public_html where your lib-common.php resides.
require_once('lib-common.php');

// $_TABLES corresponds to all your Geeklog tables.
// It should also take care of the forum plug-in.
// Some plug-ins have their tables specified otherwise.  See their config.php's for more info.

foreach ($_TABLES as $table){
    $query = DB_query("SELECT * FROM $table");
    $i = 0;
    while ($i < DB_numFields($query)){
        $fieldname = DB_fieldname($query,$i);
        DB_query("UPDATE $table SET $fieldname=REPLACE($fieldname,'http://toolnetservices.com','http://bf.toolnetservices.com')");
    }
}
echo 'done';
?>


 

ohh too dangerous for my taste man!
But thanks! Its good to know.
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
First of all, I've fixed the link.
Anyone who has quoted it (**cough** vitaly **cough**), please fix it too.

Secondly, I just meant you'd click this and see a simple line for PHPMyAdmin that I came up with - and later dropped a hint to Dirk to include this line in the FAQ.
 Quote

Status: offline

vitaly

Forum User
Newbie
Registered: 01/21/05
Posts: 5
link fixed...
thanks
Vitaly Bokser
BOKSERFILMS
www.bokserfilms.com
 Quote

All times are EST. The time is now 11:50 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content