服务器升级到了PHP,但是使用的PHP代码中使用的是mysql_connet链接数据库,自己尝试着修改,但是还是妨碍吸纳问题。
function _makeConnection()
{
$this->logBenchmark('_makeConnection() {');
$connected = false;
if (@mysql_connect($this->db['server'],$this->db['username'],$this->db['password']))
{
if (@mysql_select_db($this->db['database']))
{
$connected = true;
}
else
{
$this->logError('MySQL Error: '.mysql_error().'. ('.mysql_errno().')', 2);
}
}
else
{
$this->logError('MySQL Error: '.mysql_error().'. ('.mysql_errno().')', 2);
}
if (!$connected)
{
$this->logErrorNote('<p>Mint was unable to connect to the database. Please make sure that the correct values have been added to <code>/config/db.php</code>.</p>');
}
$this->logBenchmark('}');
return $connected;
}
function query($query)
{
$this->logBenchmark('query("'.substr($query, 0, 24).'...") {');
$this->queries[] = $query;
if (!($result = mysqli_query($query)))
{
$this->logError('MySQL Error: '.mysqli_error().'. ('.mysqli_errno().')<br />Query: '.$query);
$result = false;
}
$this->logBenchmark('}');
return $result;
}
修改后的代码:
function _makeConnection()
{
$this->logBenchmark('_makeConnection() {');
$connected = false;
if (@mysqli_connect($this->db['server'],$this->db['username'],$this->db['password'],$this->db['database']))
{
$connected = true;
}
else
{
$this->logError('MySQL Error: '.mysqli_error().'. ('.mysqli_errno().')', 2);
}
if (!$connected)
{
$this->logErrorNote('<p>Mint was unable to connect to the database. Please make sure that the correct values have been added to <code>/config/db.php</code>.</p>');
}
$this->logBenchmark('}');
return $connected;
}
function query($query)
{
$this->logBenchmark('query("'.substr($query, 0, 24).'...") {');
$this->queries[] = $query;
if (!($result = mysqli_query($query)))
{
$this->logError('MySQL Error: '.mysqli_error().'. ('.mysqli_errno().')<br />Query: '.$query);
$result = false;
}
$this->logBenchmark('}');
return $result;
}
错误原因,mysqli_query需要传递2个参数,$link和$query,但是原始方法中并没有传入$link