| CATEGORIES |
| PHP ARTICLES |
|
Browse All PHP Articles
Latest 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 |