Changing HTML in Posts in the Database via SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samir
    Senior Member
    • Nov 2003
    • 287
    • 3.8.x

    Changing HTML in Posts in the Database via SQL

    I've had a service provider I use for html slideshows change their parameter format, so all my hundreds of manually embedded slideshows have stopped working.

    It's over 20hrs of work to manually fix everything, but I'm thinking there should be a way to find an replace strings directly in the database, right? Could an sql query be created that can just 'find and replace' everything I need?

    Any assistance appreciated. Feel free to ask whatever questions necessary to get the details you need to help me.
    Huntsville's Premiere Car and Bike e-magazine: www.huntsvillecarscene.com
  • Samir
    Senior Member
    • Nov 2003
    • 287
    • 3.8.x

    #2
    I've run across the SQL Replace function in my research:
    The REPLACE function in SQL is used to update the content of a string.


    Has anyone tried using this to change post information?
    Huntsville's Premiere Car and Bike e-magazine: www.huntsvillecarscene.com

    Comment

    • Andy
      Senior Member
      • Jan 2002
      • 5886
      • 4.1.x

      #3
      This is the query you need to use:

      UPDATE post SET pagetext = REPLACE(pagetext, 'old name', 'new name')

      Always backup before running a query just in case.

      Comment

      • Samir
        Senior Member
        • Nov 2003
        • 287
        • 3.8.x

        #4
        Thank you! I'll be backing up and turning off my site before trying anything.

        What exactly does each piece of that query do? So that I better understand what I'm doing.
        Huntsville's Premiere Car and Bike e-magazine: www.huntsvillecarscene.com

        Comment

        • Andy
          Senior Member
          • Jan 2002
          • 5886
          • 4.1.x

          #5
          Originally posted by Samir
          Thank you! I'll be backing up and turning off my site before trying anything.

          What exactly does each piece of that query do? So that I better understand what I'm doing.
          Could you post the parameter format that you currently have and the one you want to use.

          Comment

          • Samir
            Senior Member
            • Nov 2003
            • 287
            • 3.8.x

            #6
            I'm not sure I'm following you on 'parameter format that you currently have'. Beside your query, I don't really have one yet. I don't even know exactly which tables the posts are contained in.

            I was going to use phpmyadmin to look around in the database and figure out where the data I want to change resides and then keep experimenting with queries until I got the result I wanted. Then I was going to restore the db and try it for real.
            Huntsville's Premiere Car and Bike e-magazine: www.huntsvillecarscene.com

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...