i am trying to make a fulltext search using phpmysql but its showing error in mysql_num_rows can you tell me what is the error.i created fulltext index and changed table engine also.
$search=mysql_real_escape_string($_POST['name']);
$sql="SELECT * FROM article WHERE MATCH(title, comment) AGAINST ('.$search.')";
$query = mysql_query($sql);
//Check if any results were returned
if(mysql_num_rows($query)>0){
//If so, cycle through the results
while($link = mysql_fetch_array($query)){
echo("<big><big><a href=show.php?id=$li开发者_Go百科nk[id] class=y>$link[title]</a></big></big> <br>");
echo('<big>' . $link['comment'] . '</big><br><br>');
//End the while
}}
Right after
$query = mysql_query($sql);
add the following
if (!$query) echo "<p>".mysql_errno().": ".mysql_error()."</p>";
It'll show you the error number and the text of the error message.
If you still don't solve it after reading the error message, your query should read
$sql="SELECT * FROM article WHERE MATCH(title, comment) AGAINST ('$search')";
but not
$sql="SELECT * FROM article WHERE MATCH(title, comment) AGAINST ('.$search.')";
Note the dots.
精彩评论