0

我有以下声明:

 SELECT bname,cnum,vnum, MATCH(vtext) AGAINST (''".$word."'') as relevance FROM kjv  WHERE MATCH(vtext) AGAINST (''".$word."'') AND bnum='".$book."' ORDER by relevance DESC, bnum, cnum, vnum LIMIT 0,1");

它返回空行,但如果我用硬编码值替换变量,一切都会通过。这些变量不为空,我知道是因为我在将它们输入框中后将它们输出到页面。谢谢

4

4 回答 4

0

嗨,如果您已经将值保存在变量中,请尝试此操作。

 SELECT bname,cnum,vnum, MATCH(vtext) AGAINST ('$word') as relevance FROM kjv    WHERE MATCH(vtext) AGAINST ('$word') AND bnum='".$book."' ORDER by relevance DESC, bnum, cnum, vnum LIMIT 0,1");
于 2013-10-07T05:06:47.317 回答
0

最好看到更多周围的代码,但我希望它是导致问题的双单引号:

SELECT bname,cnum,vnum, MATCH(vtext) AGAINST ('".$word."') as relevance FROM kjv  WHERE MATCH(vtext) AGAINST ('".$word."') AND bnum='".$book."' ORDER by relevance DESC, bnum, cnum, vnum LIMIT 0,1");
于 2013-10-06T21:30:33.513 回答
-1

试试这样:

SELECT bname,cnum,vnum, MATCH(vtext) AGAINST ("$word") as relevance
FROM kjv  WHERE MATCH(vtext) AGAINST ("$word") AND bnum= "$book" 
ORDER by relevance DESC, bnum, cnum, vnum LIMIT 0,1");
于 2013-10-06T21:32:26.810 回答
-1

尝试

mysql_query("SELECT bname,cnum,vnum, MATCH(vtext) AGAINST($word) as relevance FROM kjv  WHERE MATCH(vtext) AGAINST ($word) AND bnum='$book' ORDER by relevance DESC, bnum, cnum, vnum LIMIT 0,1");
于 2013-10-06T21:30:29.507 回答