Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:58:17+00:00 2026-05-27T08:58:17+00:00

Our forum is based on phpbb3 and for sometime we have been using a

  • 0

Our forum is based on phpbb3 and for sometime we have been using a syntax highlight mod. We’ve decided to drop the mod and return to the basic bbcode tags. Long story short – I need to update mySQL fields (phpbb_forum_posts, post_text) that contain:

Text Text Text Text Text 
[swordfish filename=code.bas]
code code code
123
code code[/swordfish]
Text Text Text Text Text 

To

Text Text Text Text Text 
[code]
code code code
123
code code[/code]
Text Text Text Text Text 

It is worth highlighting that [swordfish filename=code.bas] could contain other fields such as [swordfish filename=code.bas abc 123]. Regardless of what’s in the first tag, it needs to be changed to [code]

This is a bit out of my “need to know” scope, and I would really appreciate if someone could help design either a mySQL or PHP script to achieve a mass update. (I know my way around the basics, not enough for advanced search/replace)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:58:18+00:00Added an answer on May 27, 2026 at 8:58 am

    Here you go:

    $regexp = '/\[(\/)?swordfish[^\]]*\]/';
    
    $push = 'REPLACE whatever_table (id, post_text)
              VALUES';
    
    $pull = 'SELECT id, post_text
               FROM whatever_table
              WHERE whatever = condition';
    
    if ( $result = $mysqli->query($pull) ) {
        while ( $row = $result->fetch_assoc() ) {
            $row['post_text'] = preg_replace($regexp, '[$1code]', $row['post_text']);
    
            $push .= sprintf(
                ' ("%s", "%s"),',
                $mysqli->real_escape_string($row['id']),
                $mysqli->real_escape_string($row['post_text'])
            );
        }
    
        $result->free();
    }
    
    $mysqli->query(rtrim($push, ','));
    

    EDIT
    Please note that the REPLACE statement is NOT complete! You would have to fetch every column and write it back (not just the two I mentioned).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying out Haystack for our django based forum site. I was
Ok, so we are using vBulletin..ya I know. Which is within our Kohana based
I have been assigned to add a forum into an in-house CMS we have
I have implemented the MOD 10 check digit algorithm using SQL, for the US
My organization has decided to encrypt certain data in our database, and I've been
We have a simple registration form for our website users where we only require
I have a project to setup an anonymous feedback form to our website. I
Post-release, I have made one small change to one form in our development site
I have a form in HTML where our users fill in the data and
We have several wizard style form applications on our website where we capture information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.