Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am 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);
like image 757
Sam Gabriel Avatar asked Jan 08 '11 17:01

Sam Gabriel


2 Answers

You are mixing mysqli and traditional mysql commands.

Use $result->fetch_array().

like image 169
Pekka Avatar answered Nov 15 '22 19:11

Pekka


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

like image 27
Chandu Avatar answered Nov 15 '22 17:11

Chandu