Guest User

Untitled

a guest
Oct 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. // Connect to your MySQL database.
  3. $hostname = "localhost";
  4. $username = "your_username";
  5. $password = "your_password";
  6. $database = "database_name";
  7.  
  8. mysql_connect($hostname, $username, $password);
  9.  
  10. // The find and replace strings.
  11. $find = "replace this string";
  12. $replace = "with this";
  13.  
  14. $loop = mysql_query("SELECT
  15. concat('UPDATE ',table_schema,'.',table_name, ' SET ',column_name, '=replace(',column_name,', ''{$find}'', ''{$replace}'');') AS s
  16. FROM
  17. information_schema.columns
  18. WHERE
  19. table_schema = '{$database}'")
  20. or die ('Cant loop through dbfields: ' . mysql_error());
  21.  
  22. while ($query = mysql_fetch_assoc($loop))
  23. {
  24. mysql_query($query['s']);
  25. }
Add Comment
Please, Sign In to add comment