Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement