NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page fulltext mysql query not working! help!

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 05-08-2005, 01:10 PM THREAD STARTER               #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



fulltext mysql query not working! help!


PHP Code:
<?php
????: NamePros.com http://www.namepros.com/programming/88679-fulltext-mysql-query-not-working-help.html

    
include('config.php');

    if( isset(
$_POST['q']) ){

        
// if a form was submitted
        
$sql "SELECT * FROM ".$config['table']." WHERE MATCH (".$config['name'].",".$config['type'].",".$config['glass'].") AGAINST ('".$_POST['q']."')";
        
        
$result mysql_query($sql);
        
        if( !
$result ){

            echo 
"could not query database: ".die(mysql_error());

        }
        
        
$b mysql_num_rows($result);
        
        echo 
$b;
        
        while( 
$a mysql_fetch_array($result) ){

            echo 
"Name: ";
????: NamePros.com http://www.namepros.com/showthread.php?t=88679
            echo 
$a['name'];

        }
    
    }
    else{

        
// if a form was NOT submitted
        // display the form
        
        
?>
        
        <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <input name="q" id="q" /><input type="submit" id="submit" />
        </form>
        
        <?php

    
}

?>
That is my script, and it dosen't work. I put [into the input named "q"] the exact value of one of the values, but it still outputs "0" to $b. Help!

Thanks
Tom
PoorDoggie is offline  
Old 05-08-2005, 02:06 PM   #2 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
can you post a built query

just echo $sql

also have you created the indexes?
adam_uk is offline  
Old 05-08-2005, 02:25 PM THREAD STARTER               #3 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by adam_uk
can you post a built query

just echo $sql

also have you created the indexes?
SELECT * FROM drinks WHERE MATCH (drink_name,drink_type,drink_glass) AGAINST ('search_term')
????: NamePros.com http://www.namepros.com/showthread.php?t=88679

what do you mean created the indexes? I did "... FULLTEXT (drink_name,drink_type,drink_glass)..." in the "create table" mysql coding.
PoorDoggie is offline  
Old 05-08-2005, 02:47 PM   #4 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
Originally Posted by PoorDoggie
SELECT * FROM drinks WHERE MATCH (drink_name,drink_type,drink_glass) AGAINST ('search_term')
????: NamePros.com http://www.namepros.com/showthread.php?t=88679

what do you mean created the indexes? I did "... FULLTEXT (drink_name,drink_type,drink_glass)..." in the "create table" mysql coding.
when using fulltext searching you need to make indexes of your data, this is where the searches are.

ie did you exectue a sql query like this:

Quote:
CREATE FULLTEXT INDEX full_index ON mytable(
mytable_title ,
mytable_caption ,
mytable_full_body
);
if you didnt this is why your fulltext searches are not operating

it can get quite complex if your searching differenent columns each time

http://www.phpfreaks.com/tutorials/129/0.php
adam_uk is offline  
Old 05-08-2005, 03:08 PM THREAD STARTER               #5 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by adam_uk
when using fulltext searching you need to make indexes of your data, this is where the searches are.
????: NamePros.com http://www.namepros.com/showthread.php?t=88679

ie did you exectue a sql query like this:



if you didnt this is why your fulltext searches are not operating

it can get quite complex if your searching differenent columns each time

http://www.phpfreaks.com/tutorials/129/0.php
what do I put where you have "mytable, mytable_title, mytable_caption & mytable_full_body"???
PoorDoggie is offline  
Old 05-08-2005, 03:14 PM   #6 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
you need to edit that query to match your table layout and the columns you want to create indexes for.

once you have the query built you need to execute it. via phpmyadmin. or via command on ssh.

if you read the article above it will explain it better than i can.
adam_uk is offline  
Old 05-08-2005, 03:21 PM THREAD STARTER               #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



thanks
PoorDoggie is offline  
Old 05-09-2005, 03:46 PM THREAD STARTER               #8 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



nope, still not working. Do you think it could be anything to do with my server? (either web server or mysql server?)
PoorDoggie is offline  
Old 05-09-2005, 03:52 PM   #9 (permalink)
RJ
NamePros Webmaster


 
RJ's Avatar
Join Date: Feb 2003
Posts: 12,930
RJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatness
 



Find Marrow Donors! Cystic Fibrosis Parkinson's Disease
Try it like this,

PHP Code:

        
// if a form was submitted

$q addslashes($_POST['q']); 
????: NamePros.com http://www.namepros.com/showthread.php?t=88679

$sql "SELECT * FROM ".$config['table']." WHERE ".$config['name']." like '%".$q."%' or ".$config['type']." like '%".$q."%' or ".$config['glass']." like '%".$q."%'"
__________________
@DomainBuyer facebook
RJ is offline  
Old 05-10-2005, 11:15 AM THREAD STARTER               #10 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by -RJ-
Try it like this,

PHP Code:

        
// if a form was submitted

$q addslashes($_POST['q']); 

$sql "SELECT * FROM ".$config['table']." WHERE ".$config['name']." like '%".$q."%' or ".$config['type']." like '%".$q."%' or ".$config['glass']." like '%".$q."%'"
????: NamePros.com http://www.namepros.com/showthread.php?t=88679
great! works... thanks!
PoorDoggie is offline  
Old 05-10-2005, 01:48 PM   #11 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
while that will work its not actually full text searching. and things like boolean searches wont work.
adam_uk is offline  
Old 05-10-2005, 02:57 PM THREAD STARTER               #12 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by adam_uk
while that will work its not actually full text searching. and things like boolean searches wont work.
you mean like: "drink +name" and "'drink name'" and stuff? I don't think that matters, it wasn't how I was gonna do it anyway! lol
????: NamePros.com http://www.namepros.com/showthread.php?t=88679

Thanks all!
PoorDoggie is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows deadserious Webmaster Tutorials 96 05-27-2007 02:24 PM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 10:46 PM
mysql problem Shof515 Programming 3 12-14-2004 10:20 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 02:17 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:12 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger