0

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

1
  • We get hundreds of questions like this every day. You'll soon get half a dozen answers spotting the syntax error. Please don't just copy the correct code and go on—learn how to do error checking yourself. Commented Dec 17, 2013 at 11:50

3 Answers 3

2

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

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

Comments

0

change to

$cat = "Available";
$sql = "SELECT title, location, date, matter, userName, emailId, phone FROM ad_usr WHERE type ='$cat'"

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.