Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Connect to your MySQL database.
- $hostname = "localhost";
- $username = "your_username";
- $password = "your_password";
- $database = "database_name";
- mysql_connect($hostname, $username, $password);
- // The find and replace strings.
- $find = "replace this string";
- $replace = "with this";
- $loop = mysql_query("SELECT
- concat('UPDATE ',table_schema,'.',table_name, ' SET ',column_name, '=replace(',column_name,', ''{$find}'', ''{$replace}'');') AS s
- FROM
- information_schema.columns
- WHERE
- table_schema = '{$database}'")
- or die ('Cant loop through dbfields: ' . mysql_error());
- while ($query = mysql_fetch_assoc($loop))
- {
- mysql_query($query['s']);
- }
Add Comment
Please, Sign In to add comment