functions.inc.php: ensure link is open for when we do escape_string stuff; update pg_escape_string usage for php > 5.2.0

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@32 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 17 years ago
parent 8bd7d6da3b
commit fc4b601b39

@ -218,17 +218,27 @@ function escape_string ($string)
}
if (!is_numeric($string))
{
$link = db_connect();
if ($CONF['database_type'] == "mysql")
{
$link = db_connect();
$escaped_string = mysql_real_escape_string($string, $link);
}
if ($CONF['database_type'] == "mysqli")
{
$link = db_connect();
$escaped_string = mysqli_real_escape_string($link, $string);
}
if ($CONF['database_type'] == "pgsql") $escaped_string = pg_escape_string($string);
if ($CONF['database_type'] == "pgsql")
{
// php 5.2+ allows for $link to be specified.
if (version_compare(phpversion(), "5.2.0", ">="))
{
$escaped_string = pg_escape_string($link, $string);
}
else
{
$escaped_string = pg_escape_string($string);
}
}
}
else
{

Loading…
Cancel
Save