mysqli_query expects parameter 1 to be mysqli
Error "mysqli_query() expects parameter 1 to be mysqli" was thrown and made me waste 2 days finding this silly mistake.
When we use mysql_query() we simply place the query string first followed by the link identifier(connection)<?phpBut when using mysqli_query(), the link comes first followed by the query string. Simple PHP Mysqli code in procedural style
$link = mysql_connect('localhost','user','password') or die(mysql_error());
$q= mysql_query("Query string",$link) or die(mysql_error());
var_dump(mysql_fetch_array ($q));
?><?phpPlease note that I use the Database.Table format in my query strings and hence the Database details are omitted in Mysql/Mysqli connect.
$link = mysqli_connect('localhost','user','password') or die(mysqli_error($link));
$q= mysqli_query($link,"Query string") or die(mysqli_error($link));
var_dump(mysqli_fetch_array ($q));
?>
-
YOU MAY ALSO LIKE
- PHP Mysql to Mysqli mistakes
