Results 1 to 14 of 14
Thread: Full Text Search Not Working
-
05-14-2006, 08:02 PM #1Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
Full Text Search Not Working
I have this snippet from one of my scripts:
PHP Code:<?
$sql = mysql_query('SELECT \'response\' FROM cspeak WHERE MATCH (you, body)'
. ' AGAINST (\'%.$you1.%\' IN BOOLEAN MODE) LIMIT 0, 30 ');
$result = mysql_result($sql, 0);
print "$result"
?>
-----------------------
| You | Response |
-----------------------
| Hello | Hello to you |
-----------------------
If this is the case, then shouldn't "Hello to you" appear on the page? Instead I get this error:
<br />
<b>Warning</b>: mysql_result(): supplied argument is not a valid MySQL result resource in <b>/home/www/connectmeonline.com/cardinespeak/indexspeak.php</b> on line <b>24</b><br />
Thanks!
-
05-14-2006, 08:05 PM #2Newbie
- Join Date
- May 2006
- Posts
- 13
Change to this:
<?
$sql = mysql_query('SELECT 'response' FROM cspeak WHERE MATCH (you, body)'
. ' AGAINST ('%.$you1.%' IN BOOLEAN MODE) LIMIT 0, 30 ');
$result = mysql_result($sql, 0);
print "$result"
?>
-
05-14-2006, 08:10 PM #3Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
I now got this error:
PHP Code:Parse error: parse error, unexpected T_STRING in /home/www/connectmeonline.com/cardinespeak/indexspeak.php on line 2
-
05-14-2006, 08:12 PM #4Newbie
- Join Date
- Jan 2003
- Posts
- 19
Rellizate's code will give an syntax error
do this:
PHP Code:<?
$sql = mysql_query('SELECT `response` FROM cspeak WHERE MATCH (you, body)'
. " AGAINST ('$you1' IN BOOLEAN MODE) LIMIT 0, 30 ");
$result = mysql_result($sql, 0);
print $result;
?>
-
05-14-2006, 08:14 PM #5Newbie
- Join Date
- May 2006
- Posts
- 13
Wait, is that all your code? Do you not have any code to connect to the database?
-
05-14-2006, 08:16 PM #6Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
I don't get a syntax error, but $result equals:
PHP Code:<br />
<b>Warning</b>: mysql_result(): supplied argument is not a valid MySQL result resource in <b>/home/www/connectmeonline.com/cardinespeak/indexspeak.php</b> on line <b>24</b><br />
-
05-14-2006, 08:17 PM #7Newbie
- Join Date
- Jan 2003
- Posts
- 19
Originally Posted by TomorrowHostingPHP Code:<?
$sql = mysql_query('SELECT `response` FROM cspeak WHERE MATCH (`you`, `body`)'
. " AGAINST ('$you1') LIMIT 0, 30 ") or die(mysql_error());
$result = mysql_result($sql, 0);
print $result;
?>Last edited by aonic; 05-14-2006 at 08:26 PM.
-
05-14-2006, 08:23 PM #8Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
It now says
PHP Code:Query was empty
Is there something else that could be causing this?
-
05-14-2006, 08:26 PM #9Newbie
- Join Date
- Jan 2003
- Posts
- 19
I edited my previous reply, try it now
-
05-14-2006, 08:31 PM #10Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
I tried two different things, and I got two different problems. I did your script exactly and got
PHP Code:Unknown column 'body' in 'where clause'
PHP Code:Can't find FULLTEXT index matching the column list
Last edited by TomorrowHosting; 05-14-2006 at 08:35 PM.
-
05-14-2006, 08:42 PM #11Newbie
- Join Date
- Jan 2003
- Posts
- 19
you need to create FULLTEXT type indexes on the columns you are trying to search
-
05-14-2006, 08:42 PM #12Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
How do I do this? I have never used FULLTEXT before...
-
05-14-2006, 08:46 PM #13Newbie
- Join Date
- Jan 2003
- Posts
- 19
check out the mysql manual
http://dev.mysql.com/doc/refman/5.0/...xt-search.html
A FULLTEXT index definition can be given in the CREATE TABLE statement when a table is created, or added later using ALTER TABLE or CREATE INDEX.
-
05-14-2006, 09:23 PM #14Web Hosting Master
- Join Date
- Nov 2005
- Location
- Maryland
- Posts
- 562
Ok, thanks a ton for your help!