The MU forums have moved to

Mysql replace links (6 posts)

  1. enseignement
    Posted 16 years ago #


    Can someone help me to replace the default links in already registered members.
    Like a "search and replace" mysql request for etc. :-)

    I've searched in the forums but did not find anything for this...

  2. tdjcbe
    Posted 16 years ago #

    To be honest, that's pretty basic (ok, maybe a little more than "basic.") server tech. Best bet would be to study the subject as there's a number of ways to do it.


  3. honewatson
    Posted 16 years ago #

  4. nologo1978
    Posted 15 years ago #

    This is an old post, but a ran across it trying to do the same thing as the person who posted this.

    I think it's pretty discouraging for people who ask a question, a pretty difficult question, and get some really elementary answers.

    Most people that are reading this are not going to be able to sit down and spend a week inserting an "update" search and replace for every field of every table.

    I used this to create a lab environment from a production database. Fill in the right global variables and the string that you want to find and replace down below. This actually should work for any search and replace for an entire database, whether wordpress or not.

    use Mysql;
    # Global variables
    # Connect string
    $connect = Mysql->connect($host, $db, $user, $pass);
    # Get tables
    $query = "show tables;";
    $execute = $connect->query($query);
    while (@results=$execute->fetchrow()) {
    	$fieldsq = "describe $results[0]";
    	$execdesc = $connect->query($fieldsq);
    	while (@fieldrslts = $execdesc->fetchrow()) {
    		$updateq = "update $results[0] set $fieldrslts[0] = replace \($fieldrslts[0],\'\',\'\'\)";
    		$execupd = $connect->query($updateq);
  5. cafespain
    Posted 15 years ago #

    Yeah, you didn't read the original post did you???

    He asked how to replace the default links for existing users.
    That's a single update SQL statement run on a MySql server - absolutely nothing to do with WPMU, which is probably why they received such answers.

  6. nologo1978
    Posted 15 years ago #

    My bad and my apologies. Nevertheless, I thought this was a bit of a pain in the ass but here's the code... take it or leave it.

About this Topic

  • Started 16 years ago by enseignement
  • Latest reply from nologo1978