bulk word replaceent in database...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • butty
    Senior Member
    • Jun 2001
    • 221

    bulk word replaceent in database...

    hello there. i wonder if someone can help me.

    i have jus moved my forum up a dir from http://www.mysite.com/forum to http://www.mysite.com

    now its all working oketc but i have some links in the database that are on posts say of people linking to other posts on my forum. they would have on the links http://www.mysite.com/forum/showthread.php? etc etc

    now is there anyways i can change all the instances of this in my database and remove the /forum so that when people visit the links to other pages on posts on my forum it will still iink to the post that its supposed to

    any help appreciated. thanks guys
    http://
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    Run a query like this on your database (backup first):

    Code:
    UPDATE post
    SET pagetext = REPLACE(pagetext,'[color=red]OLD TEXT[/color]','[color=red]NEW TEXT[/color]')

    Comment

    • GlitterKill
      Member
      • Aug 2002
      • 45
      • 3.8.x

      #3
      Is this case sensitive? I am wanting to do the same thing since we recently changed our site name and I want to rename all of the links as well as change the occurances of our old name to our new one.
      Admin, http://www.pcapex.com

      Comment

      • GlitterKill
        Member
        • Aug 2002
        • 45
        • 3.8.x

        #4
        Bump... Anyone know if this is case sensitive? Can it be made case sensitive if not?
        Admin, http://www.pcapex.com

        Comment

        • Jake Bunce
          Senior Member
          • Dec 2000
          • 46598
          • 3.6.x

          #5
          I just tested it. It is case-sensitive.

          Comment

          • GlitterKill
            Member
            • Aug 2002
            • 45
            • 3.8.x

            #6
            Great! Thanks!

            I have another question though. Since this changes post text, will it also affect urls/links? The main thing I want to change are all links within the site from pimprig.com to pcapex.com. So say somthing like this:

            Sample link.

            Will the actual words in that url be changed via the same method? I have a large board with over 500K posts and 11K members so I am just being extra careful.
            Last edited by GlitterKill; Wed 25 Jan '06, 8:27am.
            Admin, http://www.pcapex.com

            Comment

            • Jake Bunce
              Senior Member
              • Dec 2000
              • 46598
              • 3.6.x

              #7
              Yes, it will change links in posts.

              Comment

              • GlitterKill
                Member
                • Aug 2002
                • 45
                • 3.8.x

                #8
                What if we need to change text that includes quotes? " "
                Admin, http://www.pcapex.com

                Comment

                • Jake Bunce
                  Senior Member
                  • Dec 2000
                  • 46598
                  • 3.6.x

                  #9
                  The query above uses single quotes ('...') to delimit the strings. You can safely use double quotes in the strings. For example:

                  Code:
                  UPDATE post
                  SET pagetext = REPLACE(pagetext,'[color=red]blah" blahblah[/color]','[color=red]no way! "quotes"[/color]')
                  ...but if you use single quotes then you need to escape them with backslashes:

                  Code:
                  UPDATE post
                  SET pagetext = REPLACE(pagetext,'[color=red]single quote \' blah blah[/color]','[color=red]bunch of them \'\' asdflkj \'[/color]')

                  Comment

                  • CerealKiller
                    Member
                    • Feb 2007
                    • 30
                    • 3.6.x

                    #10
                    I hate to bump such an old thread, but at least this way you know I searched .

                    I moved my forums from http://forums.rhinoforums.net to http://www.rhinoofurm.net/ so I wanted to run this command:


                    Code:
                    UPDATE post
                    SET pagetext = REPLACE(pagetext,'http://forums.rhinoforums.net','http://www.rhinoforums.net')
                    However, when I ran the query via the 'AdminCP > Execute SQL Query' this was returned:

                    An error occurred while attempting to execute your query. The following information was returned.
                    error number: 1146
                    error desc: Table 'rhinoDB.post' doesn't exist


                    Any help? Thank you.

                    Comment

                    • Reeve of Shinra
                      Senior Member
                      • Sep 2001
                      • 4325
                      • 4.0.0

                      #11
                      Just use the replacement feature under admincp -> styles and settings -> replacement variables -- then input the stuff under the style your using. Its done on the fly but it will work.
                      Plan, Do, Check, Act!

                      Comment

                      • pds
                        Member
                        • Jan 2003
                        • 85
                        • 3.8.x

                        #12
                        Originally posted by Jake Bunce
                        Run a query like this on your database (backup first):

                        Code:
                        UPDATE post
                        SET pagetext = REPLACE(pagetext,'[color=red]OLD TEXT[/color]','[color=red]NEW TEXT[/color]')

                        This didn't work on my 3.7.2 version. Any suggestions? I changed some usernames, and want the posts with their prior posts quoted to have the correct username.

                        Do I have to run any maintenance scripts to make the changes show up?
                        Paul

                        "Whoever believes in Telekinesis, raise my hand."

                        Comment

                        • peterska2
                          Senior Member
                          • Oct 2003
                          • 8869
                          • 3.7.x

                          #13
                          Please start your own thread in the relevant forum for the version of vBulletin that you are running. Thank you.

                          Comment

                          Related Topics

                          Collapse

                          Working...