Blog Entries

jaki levy auto-blogs on new media, iTV, and performance on the web. what’s that? he doesn’t know.

Fixing WordPress after it Crashes

My WordPress Blog crashed this weekend while I was updating it. I was adjusting the values in Options -> General and made a mistake: I set the value in the WordPress URL field to be my root directory (www.jakilevy.com) instead of where it is currently.
I could not login, or reset the value.

WordPress options general

I had to go into my database.

This was helpful during my process :: http://www.tamba2.org.uk/wordpress/site-url/ :: but it wasn’t what saved me.
Since my host does not have PHPmyAdmin, I had a difficult time accessing my database.

My friend, Michael, who started his own business, Help With a Smile, is what really saved me.

He wrote a PHP script for me that reset the necessary value in the database.
Here’s the script:

define('DB_NAME', 'Database_name'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'mysql.yoursite.org'); // 99% chance you won't need to change this value

// MAKE THE CONNECTION
$db_conn = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) OR die('Could not connect to MySQL: '.mysql_error());

// SELECT THE DATABASE
@mysql_select_db(DB_NAME) or trigger_error('Could not select the mysql database: '.mysql_error());

$query = "UPDATE wp_options SET option_value='http://www.yoursite.come/blog' WHERE option_name='siteurl' LIMIT 1";
$result = mysql_query($query) or trigger_error('Mysql Error: '.mysql_error());

$rows_affected = mysql_affected_rows();
echo "$rows_affected rows changed.";

?>

In order to use the script, you must change the values to reflect your database. If you don’t have the values readily available, you can get them from your wp-config file on your server.

Copy the code above. Insert into a text editor. Save as fixwordpress.php. Upload to your site: www.yoursite.com/blog.
Enter the URL: www.yoursite.com/blog/fixwordpress.php

Congratulations. Your site is fixed.

Sphere: Related Content

in General → 0 Comments Tweet This

 

Leave a Reply