I'm new to mysql and was wondering if someone could help me
Im using the following code on search engine on my site I have to table blog and news when i change blog to news and post to article the error disappears but when i change it back i get the Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource.
I have now idea what the error is can anyone help me much appreciated.
copy of the the query code:
<?php
include ('../config.php');
$RESULTS_LIMIT=10;
if(isset($_GET['search_term']) && isset($_GET['search_button']))
{
$search_term = $_GET['search_term'];
if(!isset($first_pos))
{
$first_pos = "0";
}
$sql_query = mysql_query("SELECT * FROM blog WHERE MATCH(title,post) AGAINST('$search_term')");
//additional check. Insurance method to re-search the database again in case of too many matches (too many matches cause returning of 0 results)
if($results = mysql_num_rows($sql_query) != 0)
{
$sql = "SELECT * FROM blog WHERE MATCH(title,post) AGAINST('$search_term') LIMIT $first_pos, $RESULTS_LIMIT";
$sql_result_query = mysql_query($sql);
}
else
{
$sql = "SELECT * FROM blog WHERE (title LIKE '%".mysql_real_escape_string($search_term)."%' OR post LIKE '%".$search_term."%') ";
$sql_query = mysql_query($sql);
$results = mysql_num_rows($sql_query);
$sql_result_query = mysql_query("SELECT * FROM blog WHERE (title LIKE '%".$search_term."%' OR post LIKE '%".$search_term."%') LIMIT $first_pos, $RESULTS_LIMIT ");
}
}
?>