Warning** : mysqli_num_rows(


Warning : mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in

Warning : mysqli_query() expects parameter 1 to be mysqli, string given in

$conn= mysqli_connect("localhost","root",""); 
	if(mysqli_connect_error()) { 
		die('Could not connect: ' . mysqli_connect_error());
$search_exploded = explode (" ", $search);
foreach($search_exploded as $search_each)
$construct .="keywords LIKE '%$search_each%'";
$construct .="AND keywords LIKE '%$search_each%'";
$constructs ="SELECT * FROM search WHERE $construct";
$run = mysqli_query($constructs,$webdes42_search);
$foundnum = mysqli_num_rows($run);
if ($foundnum==0)
echo "Sorry, there are no matching result for <b>$search</b>.</br></br>1. 
Try more general words. for example: If you want to search 'how to create a website'
then use general keyword like 'create' 'website'</br>2. Try different words with similar
 meaning</br>3. Please check your spelling";

i need help


Have you tried echoing $constructs to see if it is what you expect before executing the query?


getting this SELECT * FROM search WHERE keywords LIKE '%Created%'AND keywords LIKE '%by%'AND keywords LIKE '%Kenneth%'AND keywords LIKE ‘%Johnson%’


I’m not sure if it’s the problem, but I can see missing spaces before the ANDs.


i need this code in mysqli


What happens when you add the missing spaces?




That look right to you?


Or what about this?

$run = mysqli_query($constructs,$webdes42_search);

I don’t do mysqli, but a quick look at the doc shows that the first parameter is not the query string, hence the second error message in the original post. The first error message comes from not checking whether or not the query executed before trying to use the results.

Not sure what’s in $webdes42_search, whether that might cause a further problem.

I presume the select_db() thing is a typo when anonymising the code for the forum.


that is db name


The database name is '? I am not trying to make fun of you. I’m just trying to figure out why your code looks weird.


A single apostrophe isn’t going to work


Permitted characters in unquoted identifiers:

  • ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)

closed #13

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.