Search its full working but when I am trying to find a word with ' like Let's..cannot find it...the error is warning...Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in myfile on line 73. Can someone find the problem or make my code to work with this word...
Code:
$search = $_GET ['search'];
mysql_connect("localhost","root","");
mysql_select_db("search");
$search_exploded = explode (" ", $search);
$x = "";
$construct = "";
foreach($search_exploded as $search_each)
{
$x++;
if($x==1)
$construct .="title LIKE '%$search_each%' OR type LIKE '%$search_each%' OR year LIKE '%$search_each%'";
else
$construct .="AND title LIKE '%$search_each%' OR type LIKE '%$search_each%' OR year LIKE '%$search_each%'";
}
$constructs ="SELECT * FROM search WHERE $construct";
$run = mysql_query($constructs);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "
<header class='page-header'>
<h1 class='page-title'>Nothing Found</h1>
</header>
<div class='page-content'>
<p style='color:#999;'>Sorry, but nothing matched your search terms. Please try again with some different keywords.</p>
<aside id='search-2' class='widget widget_search'>
<form role='search' method='get' class='search-form' action='s'>
<label>
<input autocomplete='off' type='search' class='search-field' placeholder='Search Again …' value='' name='search' title='Search for:'>
</label>
<input type='submit' class='search-submit' value='Search'>
</form>
</aside>
</div></div>
";
else
{
echo"
<header class='page-header'>
<h1 class='page-title'>Search results for <b>'$search'</b></h1>
</header>
";