php - mysqli_fetch_array expects parameter 1 to be mysqli_result, null -
this question has answer here:
hey working on code create list of students depending on entry on html form. receiving following error:
warning: mysqli_query() expects parameter 1 mysqli, string given in ..... on line 15.
i have made lot of changes , rearrangements can't seem work. hints of absolutely amazing!!
the code is:
<?php require_once 'connect.php'; mysql_select_db("db_ll20g11"); if ($_post ['criterion'] == 'c'){ $status = 'current'; echo 'current students list<br/>'; } else{ $status ='left'; echo' left students list <br/>'; } $listings = "select * student status ='".$status."'"; $results = mysqli_query($listings, $connect); //mysqli_fetch_query not working while ($row = mysqli_fetch_array($results)) { echo 'name:' .$row['name'] . " " .' date of birth:' .$row['dateofbirth'] . " " . 'gender:' .$row['gender'] . " " .'email:' .$row['email']. " "; } echo '<br />'; ?>
thank you.
you did confuse parameter order.
see under http://php.net/mysqli_query:
procedural style
mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = mysqli_store_result ] )
so, write:
$results = mysqli_query($connect, $listings);
and don't use mysql , mysqli in same code: mysql_select_db("db_ll20g11");
won't work here in combination mysqli.
use:
$connect = new mysqli("host", "user", "pass", "db_ll20g11");
Comments
Post a Comment