I've a php, which displays rows from a MySQL DB, sql query is like this
$cat = 'Available'
$sql = "SELECT title, location, date, matter, userName, emailId, phone FROM ad_usr WHERE type =".$cat;
query works fine in mysql.
but when try to execute following codes
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_assoc($result);
gives an error like this
"mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given"
but when I use $cat
serialNo instead of type and $cat
as an integer then it works fine
You have missed to close the "
$sql = "SELECT title, location, date, matter, userName, emailId, phone FROM ad_usr WHERE type ='$cat'";
You can able to find these errors yourself, if you use editor like eclipse
and etc
change to
$cat = "Available";
$sql = "SELECT title, location, date, matter, userName, emailId, phone FROM ad_usr WHERE type ='$cat'"
You don't need to guess. The Quick Start Guide has several usage examples. Please have a look at Executing statements ; most examples listed there show how to do error checking.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.