hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Full Text Search Not Working
Reply

Forum Jump

Full Text Search Not Working

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-14-2006, 08:02 PM
TomorrowHosting TomorrowHosting is offline
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($sql0);
       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!

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting




Sponsored Links
  #2  
Old 05-14-2006, 08:05 PM
Rellizate Rellizate is offline
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"
?>

  #3  
Old 05-14-2006, 08:10 PM
TomorrowHosting TomorrowHosting is offline
Web Hosting Master
 
Join Date: Nov 2005
Location: Maryland
Posts: 558
I now got this error:
PHP Code:
Parse errorparse errorunexpected T_STRING in /home/www/connectmeonline.com/cardinespeak/indexspeak.php on line 2 

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting


Sponsored Links
  #4  
Old 05-14-2006, 08:12 PM
aonic aonic is offline
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($sql0);
       print 
$result;
?>

  #5  
Old 05-14-2006, 08:14 PM
Rellizate Rellizate is offline
Newbie
 
Join Date: May 2006
Posts: 11
Wait, is that all your code? Do you not have any code to connect to the database?

  #6  
Old 05-14-2006, 08:16 PM
TomorrowHosting TomorrowHosting is offline
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</bon line <b>24</b><br /> 
just like it did before.

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting


  #7  
Old 05-14-2006, 08:17 PM
aonic aonic is offline
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</bon 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($sql0);
       print 
$result;
?>


Last edited by aonic; 05-14-2006 at 08:26 PM.
  #8  
Old 05-14-2006, 08:23 PM
TomorrowHosting TomorrowHosting is offline
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?

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting


  #9  
Old 05-14-2006, 08:26 PM
aonic aonic is offline
Newbie
 
Join Date: Jan 2003
Posts: 19
I edited my previous reply, try it now

  #10  
Old 05-14-2006, 08:31 PM
TomorrowHosting TomorrowHosting is offline
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.

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting



Last edited by TomorrowHosting; 05-14-2006 at 08:35 PM.
  #11  
Old 05-14-2006, 08:42 PM
aonic aonic is offline
Newbie
 
Join Date: Jan 2003
Posts: 19
you need to create FULLTEXT type indexes on the columns you are trying to search

  #12  
Old 05-14-2006, 08:42 PM
TomorrowHosting TomorrowHosting is offline
Web Hosting Master
 
Join Date: Nov 2005
Location: Maryland
Posts: 558
How do I do this? I have never used FULLTEXT before...

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting


  #13  
Old 05-14-2006, 08:46 PM
aonic aonic is offline
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.

  #14  
Old 05-14-2006, 09:23 PM
TomorrowHosting TomorrowHosting is offline
Web Hosting Master
 
Join Date: Nov 2005
Location: Maryland
Posts: 558
Ok, thanks a ton for your help!

__________________
Need C Class Diversity For Your SEO Campaigns?

Get SEO Hosting From Arctic Hosting


Reply

Related posts from TheWhir.com
Title Type Date Posted
Do Offsite Search Marketing Strategies Still Matter? Blog 2014-01-15 16:30:47
Mistakes To Avoid When Launching A New Website Design Blog 2014-01-10 10:53:50
Why You Should Embrace Google Plus Blog 2013-03-08 09:18:17
Are you ready for Speed Networking at WHIR Events? Blog 2013-01-18 07:00:04
How 1&1 Internet's New SEO Spotlight Tool Will Help Boost SMBs Search Rankings Web Hosting News 2012-11-12 13:52:18


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?