SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Connect to your MySQL database.
  3. $hostname = "localhost";
  4. $username = "db_username";
  5. $password = "db_password";
  6. $database = "db_name";
  7.  
  8. mysql_connect($hostname, $username, $password);
  9.  
  10. // The find and replace strings.
  11. $find = "find_this_text";
  12. $replace = "replace_with_this_text";
  13.  
  14. $loop = mysql_query("
  15.     SELECT
  16.         concat('UPDATE ',table_schema,'.',table_name, ' SET ',column_name, '=replace(',column_name,', ''{$find}'', ''{$replace}'');') AS s
  17.     FROM
  18.         information_schema.columns
  19.     WHERE
  20.         table_schema = '{$database}'")
  21. or die ('Cant loop through dbfields: ' . mysql_error());
  22.  
  23. while ($query = mysql_fetch_assoc($loop))
  24. {
  25.         mysql_query($query['s']);
  26. }
  27. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top