$string .= " host=$host";
}
- if (defined('DB_PORT')) {
+ if (defined('DB_PORT') && DB_PORT) {
$string = "$string port=" . DB_PORT;
}
$link = pg_connect($string);
if (!$link) {
- die("Connection failed: " . pg_last_error($link));
+ die("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
}
return $link;
}
return $link;
} else {
- die("Connection failed: " . mysql_error($link));
+ die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
}
}
}
-function db_escape_string($s, $strip_tags = true) {
+function db_escape_string($link, $s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
if (DB_TYPE == "pgsql") {
- return pg_escape_string($s);
+ return pg_escape_string($link, $s);
} else {
- return mysql_real_escape_string($s);
+ return mysql_real_escape_string($s, $link);
}
}
function db_query($link, $query, $die_on_error = true) {
- //if ($_REQUEST["qlog"])
- // error_log($_SESSION["uid"] . ":" . $_REQUEST["op"] . "/" . $_REQUEST["method"] .
- // " $query\n", 3, "/tmp/ttrss-query.log");
-
if (DB_TYPE == "pgsql") {
$result = pg_query($link, $query);
if (!$result) {