Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1588404
  • 博文数量: 317
  • 博客积分: 10283
  • 博客等级: 上将
  • 技术积分: 3566
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-04 11:38
个人简介

哥使用Linux

文章分类

全部博文(317)

分类: LINUX

2008-04-23 22:05:13

在Open SuSE上搭建Postfix的时候,用postfixadmin建立domain的时候,发现居然不能建立。apache日志不停地报错:


[Wed Apr 23 21:22:14 2008] [error] [client 192.168.4.178] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /parth/postfixadmin/functions.inc.php on line 131, referer:

看来是functions.inc.php除数出现了问题啊。发现没有问题啊。以前在RHEL和Debian上配置都没有遇到问题,后来实在没有办法。就直接google去了,发现的确是这个函数出现了问题。主要原因是由于apache代替postfixadmin来连接mysql,导致出错。


I have already configured the file config.inc.php and everything seems to be in order. However, if you look at the error, you will notice that Postfixadmin is actually trying to connect to the MySQL server as "apache" instead of as "postfixadmin" which is what was configured in config.inc.php.

解决办法:


I managed to recall how I fixed it the last time so I hope this would be useful to anyone who tried to use Postfixadmin with magic_quotes turned off.

Open functions.inc.php and go to line 126.

Find this
Quote:
function escape_string ($string)
{
global $CONF;
if (get_magic_quotes_gpc () == 0)
{
if ($CONF['database_type'] == "mysql") $escaped_string = mysql_real_escape_string ($string);
if ($CONF['database_type'] == "mysqli") $escaped_string = mysqli_real_escape_string ($string);
if ($CONF['database_type'] == "pgsql") $escaped_string = pg_escape_string ($string);
}
else
{
$escaped_string = $string;
}
return $escaped_string;
}

Add this 1 line

Quote:
$link = db_connect();

Now the code will look like this

Quote:
function escape_string ($string)
{
global $CONF;
if (get_magic_quotes_gpc () == 0)
{
$link = db_connect();
if ($CONF['database_type'] == "mysql") $escaped_string = mysql_real_escape_string ($string);
if ($CONF['database_type'] == "mysqli") $escaped_string = mysqli_real_escape_string ($string);
if ($CONF['database_type'] == "pgsql") $escaped_string = pg_escape_string ($string);
}
else
{
$escaped_string = $string;
}
return $escaped_string;
}

Now it should work.


原文来自:


阅读(1933) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~