Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Sep 2002
Posts: 151
Member
Member
Offline
Joined: Sep 2002
Posts: 151
Alright... next issue on my cleaning program.

I have changed the name of my forum and files folders. Updating the UBBT 6.4 configs was easy and everything works fine.

But... (there´s always a but ) ... I now have this cosmetic issue:

Lots of posts have links to graemlins that don´t work now.
Lots of users have avatar link that don´t work.

I know one way to fix this:
Export these tables to a text file.
Do search & replace to edit url´s.
Dump the textfile on the database

With a backup of the database, this should´t be too dangerous. But it will be lots and lots and lots of search and replace.

So my obvious question is if there is annoher way to do this?

Sponsored Links
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Sure, but it would require some scripting.
Basically the php script would search for all posts containing the search word, then it would go through the results, replace the word with what you want it to be, then write the post back to the database.

Joined: Sep 2002
Posts: 151
Member
Member
Offline
Joined: Sep 2002
Posts: 151
Ok...sound like a good way to go.

Any idea on how a script like that would look like?

I think that the only fields to search are these:
w3t_Users / U_Picture
w3t_Posts / B_Picture, B_Body


Last edited by Gregori; 01/03/2004 7:13 AM.
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
I could look into writing something like that...

Joined: Jul 2001
Posts: 1,157
Likes: 82
coffee and code
coffee and code
Joined: Jul 2001
Posts: 1,157
Likes: 82
any updates to this ?


current developer of UBB.threads php forum software
current release: UBB.threads 8.0.0 // wip: UBB.threads 8.0.1
isaac @ id242.com // my forum @ CelicaHobby.com
Sponsored Links
Joined: Jul 2001
Posts: 1,157
Likes: 82
coffee and code
coffee and code
Joined: Jul 2001
Posts: 1,157
Likes: 82
nevermind... i found it

Code
update yourtable set fieldname = replace(fieldname,'oldphrase','newphrase')


it's case sensitve though... but atleast it works


current developer of UBB.threads php forum software
current release: UBB.threads 8.0.0 // wip: UBB.threads 8.0.1
isaac @ id242.com // my forum @ CelicaHobby.com
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Are you sure this is what you searched for?

"REPLACE works exactly like INSERT, except that if an old record in the
table has the same value as a new record on a unique index, the old
record is deleted before the new record is inserted.
See section 7.21 INSERT syntax."

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
UPDATE w3t_Posts SET B_Body = REPLACE(B_Body, 'cgi-bin','ubb')

This is the proper syntax

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Are you sure this is what he wants?
Are you sure this construct even exists in MySQL?


His problem as far I understand it is:

He has posts which have

blablablablablablablablabla <img src="/path_old/gramlin.gif"> blablablablabla

in the body or a signature of a post.

He wants to replace the /path_old/ with /path_new/ .

I don´t see how this should work with the above command.

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Hmm...apparently you are right, one learns something new every day:
http://www.joegrossberg.com/archives/000933.html

Sponsored Links
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
I would not have posted it if it was not correct

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
I would

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
[]Omegatron said:
I would not have posted it if it was not correct [/]

Omego is never wrong. Feel the Power of Cheese

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I didn't think there was such a thing either. But Rick posted it somewhere here a while ago. Quite useful.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Scroungr Please

Nah Rick gave me that little useful query a few months ago as I used it a few years ago and forgot it. ;(

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
Okay sorry Omego Anyways heres the only thing I can find and its from Gardener. Its on post

https://www.ubbdev.com/forum/showflat...prev=#Post52206

[] OK, that sounds nasty. =/ It would really have to be a new feature of the import script then, I guess.

Here is a code snippet that might help you, it updates the body and subject of all posts and does a str_replace on each one. It isn't tested though, so beware!

code: $query = "
SELECT B_Number,B_Username,B_Subject,B_Body
FROM w3t_Posts
";
$sth = $dbh -> do_query($query);

while ( list($Number,$Username,$Subject,$Body) = $dbh -> fetch_array($sth) ) {
$Body_q = addslashes(str_replace("oldstring", "newstring", $Body));
$Subject_q = addslashes(str_replace("oldstring", "newstring", $Subject));
$Number_q = addslashes($Number);
$query = "
UPDATE w3t_Posts SET
B_Body = '$Body_q'
B_Subject = '$Subject_q'
WHERE B_Number = $Number_q
";
$sth2 = $dbh -> do_query($query);
}

[/]

Joined: Jun 2003
Posts: 1,025
Junior Member
Junior Member
Offline
Joined: Jun 2003
Posts: 1,025
[]Omegatron said:
Scroungr Please

Nah Rick gave me that little useful query a few months ago as I used it a few years ago and forgot it. ;( [/]

You've forgotten more about this stuff than I will ever know.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Yeah well scroungr the mysql query above does all that without any scripting.

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
so I guess thats not the one then Oh well I did an advanced search and came up blank.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Thats cause where the query I posted is posted you do not have access too so it will not come back in a search

Joined: Jul 2001
Posts: 1,157
Likes: 82
coffee and code
coffee and code
Joined: Jul 2001
Posts: 1,157
Likes: 82
[]Omegatron said:
Thats cause where the query I posted is posted you do not have access too so it will not come back in a search [/]

The one I posted (right above yours ) came from...

http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/27/pid/436/qid/753898


current developer of UBB.threads php forum software
current release: UBB.threads 8.0.0 // wip: UBB.threads 8.0.1
isaac @ id242.com // my forum @ CelicaHobby.com
Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
OK, I grabbed the "Generic Threads Page" for quick access to the database, and dropped the below code in the HTML area (or PHP area in this case)

Code
$query = "<br />SELECT B_Number,B_Username,B_Body <br />FROM w3t_Posts <br />WHERE B_Number='213'<br />";<br />$sth = $dbh -> do_query($query);<br /><br />while (list($Number,$Username,$Body) = $dbh -> fetch_array($sth) ) {<br />$Body_q = addslashes(str_replace("&amp;lt;b&amp;gt;", "<b>", $Body));<br />$Number_q = addslashes($Number);<br />$query = "<br />UPDATE w3t_Posts SET<br />B_Body = '$Body_q'<br />WHERE B_Number = $Number_q<br />";<br />$sth2 = $dbh -> do_query($query);<br />}


Getting this:

SQL ERROR: Thu, Feb 19 2004 07:45:27 -0700 Database error only visible to forum administrators

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/medar/public_html/forums/mysql.inc.php on line 133
Done


Any idea what is goofed?

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Unless you're using an old version (pre 6.1 or 6.2 I think)
There is no B_Username field in the Posts Table.

There's B_PosterId which is the user number of the user who made the post.

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
LOL I am tired.

Trying it again in a bit.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,575
Posts293,930
Members13,823
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)