12

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); 
0

3 Answers 3

44

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

Sign up to request clarification or add additional context in comments.

Comments

8

You are mixing mysqli and traditional mysql commands.

Use $result->fetch_array().

3 Comments

The first line should also use $mysqli->connect_error, not mysql_error().
But now I get : Fatal error: Call to undefined method mysqli_stmt::fetch_array() in /var/www/JMToday/loginchk.php on line 52
@Sam you need to use query() instead of execute(), that returns a result object that contains the fetch_array method. See here for a full example: php.net/manual/en/mysqli.query.php
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.