[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 05-08-2005, 12:10 PM   #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie 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

    
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: ";
            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, 01:06 PM   #2 (permalink)
Senior Member
 
Join Date: May 2003
Posts: 2,211
6,170.25 NP$ (Donate)

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, 01:25 PM   #3 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
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')

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, 01:47 PM   #4 (permalink)
Senior Member
 
Join Date: May 2003
Posts: 2,211
6,170.25 NP$ (Donate)

adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough

Breast Cancer
Quote:
Originally Posted by PoorDoggie
SELECT * FROM drinks WHERE MATCH (drink_name,drink_type,drink_glass) AGAINST ('search_term')

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, 02:08 PM   #5 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by adam_uk
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:



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, 02:14 PM   #6 (permalink)
Senior Member
 
Join Date: May 2003
Posts: 2,211
6,170.25 NP$ (Donate)

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, 02:21 PM   #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


thanks
PoorDoggie is offline  
Old 05-09-2005, 02:46 PM   #8 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie 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, 02:52 PM   #9 (permalink)
RJ
NamePros Founder

Administrator

 
Join Date: Feb 2003
Location: Bay Area, CA
Posts: 13,173
104,201.68 NP$ (Donate)

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
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."%'";
RJ is offline  
Old 05-10-2005, 10:15 AM   #10 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
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."%'";
great! works... thanks!
PoorDoggie is offline  
Old 05-10-2005, 12:48 PM   #11 (permalink)
Senior Member
 
Join Date: May 2003
Posts: 2,211
6,170.25 NP$ (Donate)

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, 01:57 PM   #12 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
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

Thanks all!
PoorDoggie is offline  
Closed Thread


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

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 01:24 PM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 09:46 PM
mysql problem Shof515 Programming 3 12-14-2004 09:20 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 01:17 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:25 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85