开发者

warning:mysql_fetch_array() expects parameter 1 to be resource, object given [duplicate]

This question already has answers here: Can I mix MySQL APIs in PHP? (4 answers) Closed 2 years ago.

I am getting the above warning when I try to run this code:

$mysqli=new mysqli("localhost", "***", "***","***") or die(mysql_error());


              function checklogin($username, $开发者_Go百科password){
                global $mysqli;


                $result = $mysqli->prepare("SELECT * FROM users WHERE username = ?");
                $result->bind_param("s", $username);
                $result->execute();

            if($result != false){

                $dbArray=mysql_fetch_array($result);


You are mixing mysql and mysqli calls in your code. Use mysqli_fetch_array instead of mysql_fetch_array.


You are mixing mysqli and traditional mysql commands.

Use $result->fetch_array().


You're using two different sets of functions... mysqli and mysql.
I think you want to use the fetch_assoc() method.

Check out http://php.net/manual/en/book.mysqli.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜