warning:mysql_fetch_array() expects parameter 1 to

2019-04-04 16:53发布

Hey guys, I'm getting the above warning when I try to run this code:

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


              function checklogin($username, $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);

3条回答
干净又极端
2楼-- · 2019-04-04 17:06

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

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-04-04 17:08

You are mixing mysqli and traditional mysql commands.

Use $result->fetch_array().

查看更多
不美不萌又怎样
4楼-- · 2019-04-04 17:29

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

查看更多
登录 后发表回答