2016-12-12 62 views
0

我是一个非常新手的Linux用户。我配置了LAMP服务器主要用于中央系统日志服务器。 Ubuntu 16.04,以及Apache,php7和mariadb的最新稳定版本。我主要关注这个教程来配置Loganalyzer(https://cloud4wi.zendesk.com/hc/en-us/articles/201827513-How-to-install-and-configure-a-SysLog-Server)。尝试安装Loganalyzer时发生PHP错误4.1.5

我成功地测试了发送系统日志消息,并可以看到数据库正在收集它们到目前为止。我也测试成功PHP可以连接到我设置的数据库rsyslog现在

<?php 
    $link = mysqli_connect("{host}", "{user}", "{password}", "{database}"); 

    if (!$link) { 
     echo "Error: Unable to connect to MySQL." . PHP_EOL; 
     echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; 
     echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; 
     exit; 
    } 

    echo "Success: A proper connection to MySQL was made!." . PHP_EOL; 
    echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL; 

    mysqli_close($link); 
    ?> 

我然后运行命令行的php -f DB-test.php的这个命令,它似乎工作。

运行Loganalyzer install.php文件时,似乎出现了我的问题。

在那里我包括数据库信息和creds的部分,它给了我一个相当无用的错误。

ERROR: Cannot use the database 'rsyslogdb'! If the database does not exists, create it or check user access permissions! Mysql Error - Description:

我检查了我的apache日志,它们似乎指向了install.php脚本的问题。最初,我得到一个错误,指出“调用未定义的函数mysql_connect”,这是我发现安装脚本使用旧函数("Call to undefined function mysql_connect()" after upgrade to php-7)的地方。这是相当好奇,从纪录分析工具的说明似乎表明他们修复了这个问题(http://loganalyzer.adiscon.com/news/loganalyzer-v4-1-5-v4-stable-released/

我只是改变了两个老功能,在脚本中使用mysqli_connect和mysqli_select_db,看看会发生什么。我进一步了,但apache日志仍然显示错误,我无法在Loganalyzer安装中继续进行。

[Mon Dec 12 15:23:21.563908 2016] [:error] [pid 1400] [client {ip}:50958] PHP Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in /var/www/html/loganalyzer/install.php on line 382, referer: http://{ip}/loganalyzer/install.php?step=3 

    >>> this is the line from install.php 
     // Try to select the DB! 
           $db_selected = mysqli_select_db($_SESSION['UserDBName'], $link_id); 
           if(!$db_selected) 
             RevertOneStep($content['INSTALL_STEP']-1, GetAndReplaceLangStr($content['LN_INSTALL_ERRORACCESSDENIED'], $_SESSION['UserDBName']) . "<br>" . DB_ReturnSimpleErrorMsg()); 


[Mon Dec 12 15:23:21.563997 2016] [:error] [pid 1400] [client {IP}:50958] PHP Warning: mysqli_errno() expects parameter 1 to be mysqli, integer given in /var/www/html/loganalyzer/include/functions_db.php on line 215, referer: http://{ip}/loganalyzer/install.php?step=3 
[Mon Dec 12 15:23:21.564013 2016] [:error] [pid 1400] [client {IP}:50958] PHP Warning: mysqli_error() expects parameter 1 to be mysqli, integer given in /var/www/html/loganalyzer/include/functions_db.php on line 215, referer: http://{ip}/loganalyzer/install.php?step=3 

    >>>> this is the line from functions_db.php 
     // Return Mysql Error 
       return "Mysql Error " . mysqli_errno($userdbconn) . " - Description: " . mysqli_error($userdbconn); 
} 

我一直在撞墙撞了我一会儿。请有人指点我正确的方向吗?

回答

0

它出现mysql_select_db的参数是错误的,这应该是mysqli_select_db(mysqli $link, string $dbname)

因此,改变线$db_selected = mysqli_select_db($link_id, $_SESSION['UserDBName']);应该纠正这个错误。

我还要检查其中$userdbconn一起被设置$link_idmysqli_errno()当前正在传递无效连接。

+0

我可以吻你!按照您的建议改变线路!现在安装完成!我还会检查mysqli_errno的其他可能的问题。再次感谢 –