From 2d407089c9a987fd53c71a6931abf890f835c908 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Fri, 23 Jul 2004 01:35:56 +0000 Subject: [PATCH] Improved error messages. git-svn-id: http://svn.automattic.com/wordpress/trunk@1475 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/wp-db.php | 88 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 17 deletions(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 10345e3d41..29e6f8cbdc 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -40,15 +40,16 @@ class wpdb { function wpdb($dbuser, $dbpassword, $dbname, $dbhost) { $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword); if (!$this->dbh) { - die("
-

Error establishing a database connection! This probably means that the connection information in your wp-config.php file is incorrect. Double check it and try again.

- -

WordPress Support Forums

-
"); + $this->bail(" +

Error establishing a database connection

+

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at $dbhost.

+ +

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

+"); } $this->select($dbname); @@ -59,14 +60,14 @@ class wpdb { function select($db) { if (!@mysql_select_db($db,$this->dbh)) { - die(" -

We're having a little trouble selecting the proper database for WordPress.

- -

WordPress Support Forums

"); + $this->bail(" +

Can’t select database

+

We were able to connect to the database server (which means your username and password is okay) but not able to select the $db database.

+ +

If you continue to have connection problems you should contact your host. If all else fails you may find help at the WordPress Support Forums.

"); } } @@ -276,6 +277,59 @@ class wpdb { } } } + + function bail($message) { // Just wraps errors in a nice header and footer +echo << + + + WordPress › Installation + + + + +

WordPress

+HEAD; +echo $message; +echo ""; +die(); + } } $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);