From c6ae077ea4162fb83ae5ae0d1d87fa0038883b67 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 21 Sep 2005 06:38:21 +0100 Subject: [PATCH] print mysql_error() on connect/query/etc failure --- db.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db.php b/db.php index 0ff7c783..9808efea 100644 --- a/db.php +++ b/db.php @@ -14,9 +14,9 @@ function db_connect($host, $user, $pass, $db) { return pg_connect($string); } else if (DB_TYPE == "mysql") { - $link = mysql_connect($host, $user, $pass); + $link = mysql_connect($host, $user, $pass) or die(mysql_error()); if ($link) { - mysql_select_db($db, $link); + mysql_select_db($db, $link) or die(mysql_error()); } return $link; } @@ -34,7 +34,7 @@ function db_query($link, $query) { if (DB_TYPE == "pgsql") { return pg_query($link, $query); } else if (DB_TYPE == "mysql") { - return mysql_query($query, $link); + return mysql_query($query, $link) or die(mysql_error()); } } @@ -42,7 +42,7 @@ function db_query_2($query) { if (DB_TYPE == "pgsql") { return pg_query($query); } else if (DB_TYPE == "mysql") { - return mysql_query($link); + return mysql_query($link) or die(mysql_error()); } } @@ -50,7 +50,7 @@ function db_fetch_assoc($result) { if (DB_TYPE == "pgsql") { return pg_fetch_assoc($result); } else if (DB_TYPE == "mysql") { - return mysql_fetch_assoc($result); + return mysql_fetch_assoc($result) or die(mysql_error()); } } -- 2.39.5