PHP Script to Reset Wordpress URL

Are you looking for a PHP script that can reset the Wordpress Address (URL) of your blog? or Did you accidentally change the settings of the Blog Address (URL) from General settings then you were not able to access your blog because of this modification that you made?

Wordpress Adress URL

Now to solve my problem, I have prepared a PHP script to reset it to my original blog settings. Here’s the PHP script for the Wordpress address URL reset that I used:

<?php
$dbhost = ‘localhost’;
$dbuser = ‘user_name’;
$dbpass = ‘password‘;
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(’Error connecting to mysql’);
$dbname = ‘databasename’;
mysql_select_db($dbname);
$query  = “UPDATE wp_options SET option_value = ‘http://www.urdomain.com‘ WHERE `wp_options`.`option_id` =1 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = ’siteurl’ LIMIT 1 ;”;
$result = mysql_query($query);
$query = “UPDATE wp_options SET option_value = ‘http://www.urdomain.com’ WHERE `wp_options`.`option_id` =39 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = ‘home’ LIMIT 1 ;”;
$result = mysql_query($query);
mysql_close($conn);
?>

You can download the whole script here: reseturl.txt and modify the portion (underlined option above) that is applicable to your site. Rename the file to reseturl.php then upload it to your website. Execute it and that’s all it will reset the Wordpress Address (URL) and Blog Address (URL) to appropriate URL.

I hope this script will solve your Wordpress problem.

Popularity: 20% [?]

bleuken

I'm a Filipino programmer and SEOptimizer from Roxas City, Capiz Philippines.

20 responses to “PHP Script to Reset Wordpress URL”

  1. eamills

    Again I screwed up, and again this helped! Thanks again

  2. abhijeet

    Thanks for this.
    I was really fall in Big problem.
    You save me!
    Thanks A lot!

  3. shezoom

    I continue to receive errors…and have tried several variations on the reseturl.php including wonderful statements such as

    Parse error: syntax error, unexpected T_STRING in /home/content/m/b/s/mbsuccess777/html/blog/reseturl.php on line 5

    So then I took a look at the wp-config.php file…located the database name and info…and now get things like

    Error establishing a database connection

    Could I forward you both files … am so lost I’m feeling blonder each and every moment.

  4. shezoom

    this sounds awesome! however how to you actually install it/run it? I made all of the recommended modifications in the script within notepad, saved it as a .php file, uploaded it to my site.

    Just don’t know where to go from here…

  5. Sci-Fi Si

    Great stuff! Thanks for that :)

  6. Sci-Fi Si

    It’s ok thanks. I went in to MySQL query browser and reset it there. Even though I couldn’t get the script working it does have the table name and ID number so I knew which values to change back.

    Many thanks

  7. Sci-Fi Si

    Humm…

    I have copied the script you have above into a text editor and saved it as reseturl.php but unfortunately I get:

    PHP Parse error: parse error in \thisisnotmywebsiteurl\reseturl.php on line 5

    I then tried to download the script link you have reseturl.txt, but unfortunately I get a Error 404.

    Do you know what is happening??

    Many thanks

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.