aboutsummaryrefslogtreecommitdiffstats
path: root/include/dblayer/functions_mysql.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/dblayer/functions_mysql.inc.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
index 6ada73a59..c21c697ae 100644
--- a/include/dblayer/functions_mysql.inc.php
+++ b/include/dblayer/functions_mysql.inc.php
@@ -32,16 +32,21 @@ define('DB_RANDOM_FUNCTION', 'RAND');
*
*/
-function pwg_db_connect($host, $user, $password, $database=null, $die=true)
+function pwg_db_connect($host, $user, $password, $database)
{
- $link = @mysql_connect($host, $user, $password) or my_error('mysql_connect', $die);
-
- return $link;
-}
-
-function pwg_select_db($database, $link, $die=true)
-{
- return @mysql_select_db($database, $link) or my_error('mysql_select_db', $die);
+ $link = @mysql_connect($host, $user, $password);
+ if (!$link)
+ {
+ throw new Exception("Can't connect to server");
+ }
+ if (mysql_select_db($database, $link))
+ {
+ return $link;
+ }
+ else
+ {
+ throw new Exception('Connection to server succeed, but it was impossible to connect to database');
+ }
}
function pwg_db_check_charset()