$qrysc = "select * from `communities` where `name` like \"%$key%\" or `type` like \"%$key%\" or `about` like \"%$key%\" union all select * from `personal` where `fname` like \"%$key%\" or `lname` like \"%$key%\" or `country` like \"%$key%\"  or `state` like \"%$key%\"  or `city` like \"%$key%\"";
$rqrysc=mysql_query($qrysc);
$numqrysc=mysql_num_rows($rqrysc);

Here communities and personal are two different tables on the same database. I am trying to search in both tables to generate output depending on the result found. I am getting error
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in F:\WORK STATION\xampplite\htdocs\GlobalDost\search\sprocess.php on line 10

line 10 is

$numqrysc=mysql_num_rows($rqrysc);

. Please tell me what's wrong or suggest me something else to achieve my goal.

Recommended Answers

All 2 Replies

1. create a view based on desired columns of both the tables
2. concatenate all the columns into a single column in the view.
3. search on the view

HI sakush100,

while appling union with two table you should have same data type in column order

so you have to check your data table structures first ....
this could be a problem....

please paste here structures of these tables here..


see php : mysql_query
if this function fails it will return false (boolean).

thats why you are getting error, because this has failed and expected result set "$rqrysc" which is now a boolean "false" we are giving to mysql_num_rows() function.

so check this out.........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.