Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Replacing Text in a MySQL Database Using PHP

By Ben Sinclair
2005-04-19


Replacing Text In A MySQL Database Using PHP

You may have the word Ben in a lot of your MySQL rows and want to repalce that word with a new word such as Jim.

If you have 10+ of rows with the name Ben in it, it could take a while having to modify each table manually...

Here is a quick and easy way to do it all at once with some simple PHP and MySQL:

<?php

// Connect to your MySQL Database here etc...

// Now with the MySQL Query
mysql_query("update table_name set text=REPLACE(text,'Ben','Jim')");

// Rest of your PHP code...
?>
Replace table_name and text with your own database fields and you're all set!

Pretty simple huh?

Enjoy! :)

Tutorial Pages:
» Replacing Text In A MySQL Database Using PHP


 | Bookmark
Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1