Results 1 to 14 of 14
  1. #1
    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($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:
    <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

  2. #2
    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. #3
    Join Date
    Nov 2005
    Location
    Maryland
    Posts
    562
    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

  4. #4
    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. #5
    Wait, is that all your code? Do you not have any code to connect to the database?

  6. #6
    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</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. #7
    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. #8
    Join Date
    Nov 2005
    Location
    Maryland
    Posts
    562
    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. #9
    I edited my previous reply, try it now

  10. #10
    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' 
    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.
    Need C Class Diversity For Your SEO Campaigns?

    Get SEO Hosting From Arctic Hosting

  11. #11
    you need to create FULLTEXT type indexes on the columns you are trying to search

  12. #12
    Join Date
    Nov 2005
    Location
    Maryland
    Posts
    562
    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. #13
    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.

  14. #14
    Join Date
    Nov 2005
    Location
    Maryland
    Posts
    562
    Ok, thanks a ton for your help!
    Need C Class Diversity For Your SEO Campaigns?

    Get SEO Hosting From Arctic Hosting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •