Okay.. I have pretty bad problem..
I have to change over 150 links in database.. from http://localhost/wordpress
to my site's url.. Does anyone know how I can do it with PHP because I really don't wanna do it manually..
And thinking is so hard for me atm.. :D that's why I ask from you :D
Changing links
Started by
Guest_Jaan_*
, Dec 25 2008 01:02 PM
5 replies to this topic
#1
Guest_Jaan_*
Posted 25 December 2008 - 01:02 PM
Guest_Jaan_*
|
|
|
#2
Posted 25 December 2008 - 01:54 PM
You don't need to use PHP, you can just use SQL. MySQL :: MySQL 5.0 Reference Manual :: 11.4 String Functions
#3
Guest_Jaan_*
Posted 25 December 2008 - 05:05 PM
Guest_Jaan_*
So.. I do like this:
[highlight="sql"]
REPLACE ("http://localhost/wordpress", "http://localhost/wordpress", "http://mysiteaddress")
[/highlight]
or something?
[highlight="sql"]
REPLACE ("http://localhost/wordpress", "http://localhost/wordpress", "http://mysiteaddress")
[/highlight]
or something?
#4
Guest_Jaan_*
Posted 25 December 2008 - 05:27 PM
Guest_Jaan_*
hmm.. I tried this:
But it didn't work
and I tried this in phpMyAdmin:
[highlight="sql"]
SELECT REPLACE('http://localhost/wordpress', 'http://localhost/wordpress', 'http://mysite');
[/highlight]
And it didn't work hmm :/
$query = mysql_query("SELECT REPLACE('http://localhost/wordpress', 'http://localhost/wordpress', 'http://mysite')");
if(!$query){
die(mysql_error());
}
But it didn't work
and I tried this in phpMyAdmin:
[highlight="sql"]
SELECT REPLACE('http://localhost/wordpress', 'http://localhost/wordpress', 'http://mysite');
[/highlight]
And it didn't work hmm :/
#5
Posted 25 December 2008 - 05:50 PM
UPDATE links set address=REPLACE(address, 'http://localhost/wordpress', 'http://mysite');
will update ALL entries in the table links within the column address having 'http://localhost/wordpress' replaced to 'http://mysite'
#6
Guest_Jaan_*
Posted 25 December 2008 - 06:10 PM
Guest_Jaan_*
Awesome.. it works mate !
thank you very much ^^
thank you very much ^^


Sign In
Create Account

Back to top









