Free Php Scripts, Articles and Resources
    home  Home   php  PHPscripts   articles  Articles   contact  Contact
Date: 11 March 2010
in

Total scripts: 203
Total downloads: 25493
Total articles: 11

Latest Scripts
Free Contact Us Script +...
Free PHP ODP Script

Top Downloaded Scripts
Captcha Security Images
dGallery

Best Rated Scripts
File Searcher
Transparent Watermark

CATEGORIES

PHP ARTICLES

<< All Php Articles



 
How to replace a text in a mysql table
 
     

Sometimes, we need to replace a text in all the entries from a mysql table.

For example, you want to replace all the absolute links from your articles with relative links. This can help you if you move the site to a new domain, or from a test server to a production server. 

You can do this very quickly, without a PHP script, using the mysql function REPLACE.   

The syntax would be something like this:

UPDATE tabel_name.column_name SET tabel_name.column_name = REPLACE(tabel_name.column_name, 'old text', 'new text');

So, to replace all the absolute urls with relative urls you can use this mysql query:

UPDATE articles.content SET articles.content  = REPLACE(articles.content, 'http://www.yourdomain.com/', '/');

 

 
<< All Php Articles