
05-14-2006, 08:02 PM
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
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"
?>
I had variable $you1 set to "Hello", and I had this in my database:
-----------------------
| 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:
Quote:
<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 />
|
What is wrong with this code?
Thanks! 
|

05-14-2006, 08:05 PM
|
|
Newbie
|
|
Join Date: May 2006
Posts: 11
|
|
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
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
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
|
|
Newbie
|
|
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
|
|
Newbie
|
|
Join Date: May 2006
Posts: 11
|
|
Wait, is that all your code? Do you not have any code to connect to the database?
|

05-14-2006, 08:16 PM
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
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 />
just like it did before.
|

05-14-2006, 08:17 PM
|
|
Newbie
|
|
Join Date: Jan 2003
Posts: 19
|
|
Quote:
|
Originally Posted by TomorrowHosting
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 />
just like it did before.
|
PHP 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
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
It now says
PHP Code:
Query was empty
, and then it terminates the rest of the script.
Is there something else that could be causing this?
|

05-14-2006, 08:26 PM
|
|
Newbie
|
|
Join Date: Jan 2003
Posts: 19
|
|
I edited my previous reply, try it now
|

05-14-2006, 08:31 PM
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
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'
I then put in "you" instead of "body" and I got
PHP Code:
Can't find FULLTEXT index matching the column list
EDIT: Also to answer Rellizate, I have more code, including code that connects me to my database.
Last edited by TomorrowHosting; 05-14-2006 at 08:35 PM.
|

05-14-2006, 08:42 PM
|
|
Newbie
|
|
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
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
How do I do this? I have never used FULLTEXT before...
|

05-14-2006, 08:46 PM
|
|
Newbie
|
|
Join Date: Jan 2003
Posts: 19
|
|
check out the mysql manual
http://dev.mysql.com/doc/refman/5.0/...xt-search.html
Quote:
|
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
|
|
Web Hosting Master
|
|
Join Date: Nov 2005
Location: Maryland
Posts: 558
|
|
Ok, thanks a ton for your help! 
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|