Jump to content

Trying to query some fulltext results with php from MySQL.


00stuff

Recommended Posts

Hi guys, i'm trying to search from a form and use php to display the results of the FullText Search from a MySQL database, but I don't get any results from the query. This is the query:  $query="SELECT * FROM tutorials WHERE MATCH(title, tags) AGAINST ('$searchform')";  I think the query is right but it doesn't give me any results.... Does anyone know what could be wrong? I think it might be something wrong with my table (database).

 

my table should have 5 columns: id, title, category, content, tags

 

The form should search throught the title and tags columns to see if it finds anything matching the $searchform , but I don't think it is doing it.

 

Can anyone help please?

Have you made title and tag fields fulltext?

 

Also im not sure if you can match 2 fields try OR instead

 

$query="SELECT * FROM `tutorials` WHERE MATCH `title` AGAINST ('{$searchform}') OR MATCH `tags` AGAINST('{$searchform}') ";

That didn't work. I got an error message. I don't think it's a problem with the code, because I copied it from another script that I had. I just changed the table name and the fields of course. How do I make sure the fields ("title,tags") are set to fulltext? I'm pretty sure that's the problem.

Ok, I clicked on the T and it added the full text, but now I get this error on the page.

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/r/o/c/rochoa1/html/itsupport/database/page/index.php on line 142

 

Line 142:    while($rowS = mysql_fetch_array($RESULT))

Hey guys, thank you very much for your help. I figured it out. I only had one entry in my database and when using FullText searches if the result takes up 50% or more it dosn't return anything. I just placed more entries and then it worked. Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.