00stuff Posted July 29, 2010 Share Posted July 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/209275-trying-to-query-some-fulltext-results-with-php-from-mysql/ Share on other sites More sharing options...
dreamwest Posted July 29, 2010 Share Posted July 29, 2010 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}') "; Quote Link to comment https://forums.phpfreaks.com/topic/209275-trying-to-query-some-fulltext-results-with-php-from-mysql/#findComment-1092790 Share on other sites More sharing options...
00stuff Posted July 29, 2010 Author Share Posted July 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209275-trying-to-query-some-fulltext-results-with-php-from-mysql/#findComment-1092799 Share on other sites More sharing options...
dreamwest Posted July 29, 2010 Share Posted July 29, 2010 In phpmyadmin select "structure" then look for the "T" hover over it and it will say "fulltext" Quote Link to comment https://forums.phpfreaks.com/topic/209275-trying-to-query-some-fulltext-results-with-php-from-mysql/#findComment-1092807 Share on other sites More sharing options...
00stuff Posted July 29, 2010 Author Share Posted July 29, 2010 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)) Quote Link to comment https://forums.phpfreaks.com/topic/209275-trying-to-query-some-fulltext-results-with-php-from-mysql/#findComment-1092811 Share on other sites More sharing options...
00stuff Posted July 29, 2010 Author Share Posted July 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209275-trying-to-query-some-fulltext-results-with-php-from-mysql/#findComment-1092814 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.