$mysql_host via "$mysql_user" using "$mysql_pass" as the password.
"; for ($cntd = 0; $cntd < count($mysql_db_names); $cntd++){ //cycle through all of the databases $dbtemp = $mysql_db_names[$cntd]; //initialize temporary variable that isn't prone to errors with brakets echo "will now edit data contained in the $dbtemp database.
"; mysql_select_db($dbtemp, $link) or die(mysql_error()); //select the proper db to operate on //database selected, now work on the tables for ($cntt = 0; $cntt < count($mysql_table_names); $cntt++){ //cycle through all of the tables $tabletemp = $mysql_table_names[$cntt]; //initialize temporary variable that isn't prone to errors with brakets echo "will now edit data contained in the $tabletemp table.
"; //table set, now work on columns for ($cntc = 0; $cntc < count($mysql_column_names); $cntc++){ //cycle through all of the columns $ctemp = $mysql_column_names[$cntc]; //initialize temporary variable that isn't prone to errors with brakets $cstatic = $mysql_column_static[$cntc]; //initialize temporary variable that isn't prone to errors with brakets echo "will now edit data contained in the $ctemp column.
"; $results = mysql_query("SELECT $cstatic, $ctemp FROM `$tabletemp` WHERE $ctemp LIKE '%$searchterm%'", $link) or die(mysql_error()); //grab the content to be updated $ucnt = 0; while ($obj = mysql_fetch_row($results)){ $staticvar = $obj[0]; $content = $obj[1]; $content2 = str_replace($searchterm, $replaceterm, $content); //the edited content //get the content strings ready for the mysql UPDATE $staticvar_escaped[$ucnt] = filter($staticvar); $content_escaped[$ucnt] = filter($content); $content2_escaped[$ucnt] = filter($content2); $ucnt++; } //now update the content for ($cnt = 0; $cnt < ($ucnt+1); $cnt++){ //change into less volatile varz $sve = $staticvar_escaped[$cnt]; $ce = $content_escaped[$cnt]; $c2e = $content2_escaped[$cnt]; //UPDATE! mysql_query("UPDATE `$tabletemp` SET $ctemp='$c2e' WHERE $cstatic='$sve' LIMIT 1", $link) or die(mysql_error()); //limit 1 update for safety $totalcnt++; //add 1 to the total amount of updates made echo ""$searchterm" has been replaced with "$replaceterm" in the $ctemp column, in the $tabletemp table.
"; } } } } mysql_close($link); //close the link when done echo "there were a total of $totalcnt updates made
"; ?>