From bbffc43e4f4c04e5efeb0edcc9851742c2223b1d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Apr 2013 16:06:03 +0400 Subject: [PATCH] actually check for DB_PORT in installer, add better hints and use mysqli if available --- config.php-dist | 2 +- install/index.php | 36 ++++++++++++++++++++++++------------ utility.css | 5 +++++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/config.php-dist b/config.php-dist index 4df29978..7cb9d939 100644 --- a/config.php-dist +++ b/config.php-dist @@ -8,7 +8,7 @@ define('DB_USER', "fox"); define('DB_NAME', "fox"); define('DB_PASS', "XXXXXX"); - //define('DB_PORT', '5432'); // when neeeded, PG-only + define('DB_PORT', ''); // usually 5432 for PostgreSQL, 3306 for MySQL define('MYSQL_CHARSET', 'UTF8'); // Connection charset for MySQL. If you have a legacy database and/or experience diff --git a/install/index.php b/install/index.php index 99339aca..9cbab20f 100644 --- a/install/index.php +++ b/install/index.php @@ -88,7 +88,7 @@ $msg"; } - function db_connect($host, $user, $pass, $db, $type) { + function db_connect($host, $user, $pass, $db, $type, $port) { if ($type == "pgsql") { $string = "dbname=$db user=$user"; @@ -101,8 +101,8 @@ $string .= " host=$host"; } - if (defined('DB_PORT')) { - $string = "$string port=" . DB_PORT; + if ($port) { + $string = "$string port=" . $port; } $link = pg_connect($string); @@ -110,10 +110,15 @@ return $link; } else if ($type == "mysql") { - $link = mysql_connect($host, $user, $pass); - if ($link) { - $result = mysql_select_db($db, $link); - if ($result) return $link; + if (function_exists("mysqli_connect")) { + return mysqli_connect($host, $user, $pass, $db, $port); + + } else { + $link = mysql_connect($host, $user, $pass); + if ($link) { + $result = mysql_select_db($db, $link); + if ($result) return $link; + } } } } @@ -173,7 +178,12 @@ } return $result; } else if ($type == "mysql") { - $result = mysql_query($query, $link); + + if (function_exists("mysqli_connect")) { + $result = mysqli_query($link, $query); + } else { + $result = mysql_query($query, $link); + } if (!$result) { $query = htmlspecialchars($query); if ($die_on_error) { @@ -254,17 +264,19 @@
- +
- + + If needed
- + + Usually 3306 for MySQL or 5432 for PostgreSQL

Other settings

@@ -327,7 +339,7 @@

Checking database