安裝bugfree時(shí),提示Mysql未安裝,找了網(wǎng)上的方法更改代碼,但是還沒有得到解決,怎么辦?
問題出現(xiàn)在bugfree安裝檢查環(huán)境時(shí),一直提示未安裝mysql。 小編百思不得其姐,? 最后發(fā)現(xiàn)問題出現(xiàn)在xampp安裝的時(shí)最新的php7.x。 7.x在原來代碼的基礎(chǔ)上移除了部分mysql的方法 所以檢測(cè)一直mysql不存在
?所以我們需要去修改bugfree的源代碼,方法如下:
修改:
bugfree\install\func.inc.php 中的checkMysql方法:
源代碼:
function checkMysql()
{
??? if(function_exists("mysql_get_client_info"))
??? {
??????? $versionInfo = mysql_get_client_info();
??????? preg_match('/[^\d]*([\d\.]+)[^\d]*/', $versionInfo, $version);
??????? $version = isset($version[1]) ? $version[1] : $versionInfo;
??????? return version_compare($version, '5.0', '>=');
??? }
??? return t('bugfree', 'Not Install');
}
?
修改后的代碼:
?
function checkMysql()
{
?? ?if(function_exists("mysqli_get_server_info"))
?? ??? ?{
?? ??? ??? ??? ??? ?$test = new mysqli("127.0.0.1", "root", "", "mysql");
?? ??? ??? ??? ??? ?if(!$test)? {
?? ??? ??? ??? ??? ??? ??? ??? ??? ?echo"database error";
?? ??? ??? ??? ??? ?}else{
?? ??? ??? ??? ??? ??? ??? ??? ??? ?echo"php env successful \n";
?? ??? ??? ??? ??? ??? ??? ??? ??? ?$versionInfo = mysqli_get_server_info($test);
?? ??? ??? ??? ??? ??? ??? ??? ??? ?printf("Server version: %s\n", mysqli_get_server_info($test));
?? ??? ??? ??? ??? ??? ??? ??? ??? ?preg_match('/[^\d]*([\d\.]+)[^\d]*/', $versionInfo, $version);
?? ??? ??? ??? ??? ??? ??? ??? ??? ?print_r($version);
?? ??? ??? ??? ??? ??? ??? ??? ??? ?$version = isset($version[1]) ? $version[1] : $versionInfo;
?? ??? ??? ??? ??? ??? ??? ??? ??? ?$test->close();
?? ??? ??? ??? ??? ??? ??? ??? ??? ?return version_compare($version, '5.0', '>=');
?? ??? ??? ??? ??? ?}
?? ??? ?}
??? return t('bugfree', 'Not Install');
}
?
還需要將上訴文件中:mysql_get_client_info()改為mysql_get_client_info() ? 刷新頁面即可
按照上述方法后,刷新還是一樣的界面
2019-03-05
查看下xampp的版本,最好裝回5.6.30的問題就解決了