php错误显示未定义的mysqli_query

时间:2017-02-07 13:21:32

标签: php mysql mariadb opensuse

我一直无法弄清问题是什么。 / var / log / apache2 / error_log显示

  

PHP致命错误:在第397行的/srv/www/htdocs/platform/includes/functions.php中调用未定义的函数mysqli_query()

我花了大量时间尝试配置灯座以便在OpenSUSE Leap上运行。任何帮助都将受到高度赞赏。

我正在使用MariaDB,PHP: mysql Ver 15.1 Distrib 10.0.28-MariaDB,适用于Linux(x86_64) PHP 5.5.14(cli

这些是相关的功能:

//functions.php
include('database.php');

function find_all_pages_index($user="guest"){
    $query = "SELECT p.pg_id,p.pg_name,p.name,u.usl_id ";
    $query .= "FROM pages as p,users as u ";
    $query .= "WHERE u.user_name=\"".strtolower($user)."\"";
    $result=mysqli_query(dbconnect(),$query) or die("Error in query"); //This is line 397

    if (mysqli_num_rows($result) > 0){
        // iterate through resultset
        // print title with links to edit and delete scripts
        echo "<ul class=\"nav navbar-nav\">";
        while($row = mysqli_fetch_row($result)){
            echo "<li";
            if (find_subjects_for_page2($row[0], $row[3]) == true){
                echo " class=\"dropdown\" >";
                echo "<a href=\"public/".  strtolower($row[1]).".php\" role=\"button\" aria-haspopup=\"true\""
            . " aria-expanded=\"false\">".$row[2]."<span class=\"caret\"></span></a>
                    <ul class=\"dropdown-menu\">";
                find_subjects_for_page($row[0],$row[3]);
            } else {
                echo ">";
                echo "<a href=\"public/".  strtolower($row[1]).".php\">";
                echo $row[2]."</a>";
            }
            echo "</li>";
            }
            echo "</ul>";
        }
}

//database.php

function dbconnect(){//function to connect to the database
    if (!defined("DB_HOST")){define("DB_HOST","localhost");}
    if (!defined("DB_USER")){define("DB_USER","platform");}
    if (!defined("DB_PWORD")){define("DB_PWORD","platform");}
    if (!defined("DB_NAME")){define("DB_NAME","platform");}
    $connection=mysqli_connect(DB_HOST,DB_USER,DB_PWORD,DB_NAME);
    if (mysqli_connect_errno()){//check if there is a connection error number
        //display error and error number if error number exists
        die ("Could not connect to database ".mysqli_connect_error()." (".mysqli_connect_errno().")");
    } else {//return connection handle if there is no error number
        return $connection;
    }     
}

function confirm_query($result,$query){
    if (!$result){//check if query was ok
        die ("Data upload failed: $query");
    }
}

1 个答案:

答案 0 :(得分:1)

我检查了this帖子并通过从OpenSUSE存储库安装软件包php5-pear-MDB2_Driver_mysqli解决了该问题。 MySQLi驱动程序丢失了。