Hi,
I’m trying to create a basic Search Engine for practice. The code is as follows:
<?php
mysql_connect("localhost", "username", "password");
mysql_select_db("timings");
$terms = explode(" ", $q);
$query = "SELECT * FROM timings WHERE ";
foreach ($terms as $key) {
$i = 0;
$i++;
if ($i == 1) {
$query .= "Last_Stop LIKE '$key' ";
} else {
$query .= "OR Last_Stop LIKE '$key' ";
}
}
$query = mysql_query($query);
$rows = mysql_num_rows($query);
if($rows > 0) {
while ($wor = mysql_fetch_assoc($query)) {
$br_no = $wor['Bus_Route_No'];
$s_stop = $wor['Start_Stop'];
$lstop = $wor['Last_Stop'];
print($br_no);
echo($s_stop);
echo($lstop);
}
} else {
echo("No Results Found");
}
?>
When I execute this script it is giving the following warning.
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given on line 54.