调用未定义的函数mysqli_query()

时间:2016-09-26 08:07:05

标签: php

你能帮我解决这个问题吗?下面的代码在localhost中工作,但不知何故,当我将此代码部署到托管时,总会出现弹出

  

致命错误:调用未定义的函数mysqli_query()   第660行/home/xxx/public_html/xxx/xxx_2/admin/function.php。

我已经在互联网上搜索解决方案,但它们都没有工作并且已经完成检查查询和查询工作了。你能给我解决这个问题的解决方案吗?

下面是我谈论的代码,

function connection (){
        $connection= new mysqli("localhost","root","","xxx_kms");
    return $connection;
}
function login($action,$timelog){
    $email=form_validation($_POST['email']);
    $password=form_validation($_POST['password']);
    $random_password=hash("sha256",$password);

        $sql="
        select ms_user.user_uid,ms_user.username,ms_user.email,ms_user.level,ms_user.division_uid,ms_division.division_uid
        from ms_user
        inner join ms_division on ms_user.division_uid=ms_division.division_uid
        where ms_user.email='".$email."' and ms_user.password='".$random_password."' and ms_user.status='0'";

        $ceksql=mysqli_query(connection(),$sql); <<--- Error appear in this line
        $result=mysqli_num_rows($ceksql);
            if($result==0){
            echo "<script>
                        alert('Username or Password is wrong');
                        window.location.href='login.php';
                </script>";
            }
            else {
                while($row=mysqli_fetch_array($ceksql)){
                    $_SESSION['user_uid']=$row['user_uid'];
                    $_SESSION['username']=$row['username'];
                    $_SESSION['division']=$row['division_uid'];
                    $_SESSION['level']=$row['level'];

                    $user_uid=$_SESSION['user_uid'];
                    $username=$_SESSION['username'];
                    $division=$_SESSION['division'];
                    $log="$username Login pada sistem";

                        if($row['level']==1){
                            sistem_log($log,$timelog,$user_uid,$division);  
                            header("location:index.php");               
                        }
                        if($row['level']==2){
                            sistem_log($log,$timelog,$user_uid,$division);  
                            header("location:../user/index.php");           
                        }

                }
            }

}

1 个答案:

答案 0 :(得分:0)

很明显,在项目中使用面向对象的样式作为Query的连接和过程样式。

您不能同时使用面向对象和面向对象的功能。向一个方向前进,无论是OOP还是非OOP。

只需更改[程序样式]的连接:

function connection (){
    $connection= mysqli_connect("localhost","root","","xxx_kms");
    return $connection;
}

检查差异here