php - 'Query was empty'-error -


here's code keep getting "query empty error". trying sql query database return answer using fulltext (newbie)

<?php include ('db_connect.inc.php'); $questions = $_get['string'];  $terms = explode(" ", $questions); $string = "select distinct answer, match(questions.questions) against('"; $string2 = "as relevance questions, answers questions.answer_id =               answers.answer_id , match(questions.questions) against('";  for($i = 0; $i < sizeof($terms); $i++) {     if($i == sizeof($terms)) {     $string = $string + $terms[$i] + "')";     $string2 = $string2 + $terms[$i] + "') limit 1"; } else {     $string = $string + $terms[$i] + ",";     $string2 = $string2 + $terms[$i] + ","; } }  $result = mysql_query($string . " " > $string2) or die(mysql_error()); echo $result;  $row = mysql_fetch_array($result); echo $row[0]; ?> 

in line:

$result = mysql_query($string . " " > $string2) or die(mysql_error()); 

the expression $string . " " > $string2 evaluate true or false, which, well, not string, let alone being valid sql query.

the reason > comparison operator that, in case, compares 2 strings lexicographically. if $string . " " after $string in lexicographical order, expression evaluates true. otherwise evaluates false false.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -