Welcome to Geeklog, Anonymous Tuesday, June 24 2025 @ 03:58 am EDT
Geeklog Forums
Search and Replace Text and/or partial strings in Geeklog DB
Status: offline
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.
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.
14
13
Quote
Status: offline
Forum User
Newbie
Registered: 01/21/05
Posts: 5
Status: offline
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!
15
13
Quote
Status: offline
Forum User
Newbie
Registered: 01/21/05
Posts: 5
that is a simple yet elegant answer, and I thank you my good man!
13
13
Quote
Status: offline
Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Pleasure!
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.
Maybe Dirk can add this hint in the FAQ.

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.

Maybe Dirk can add this hint in the FAQ.
20
12
Quote
Status: Banned
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.
<?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';
?>
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';
?>
16
11
Quote
Status: Banned
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.
13
11
Quote
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.
<?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';
?>
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.
16
13
Quote
Status: offline
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Status: offline
Forum User
Newbie
Registered: 01/21/05
Posts: 5
link fixed...
thanks
thanks
30
12
Quote
All times are EDT. The time is now 03:58 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