Solved

php sql full text

Posted on 2003-11-05
16
183 Views
Last Modified: 2010-07-27
hi all,,,


This is mySQl query work works no promlem in the DB but not in php ...why


SQL

           SELECT directory. * ,
MATCH (
keywords, title
)
AGAINST (
'%%%pottery%%'
) AS score
FROM directory
WHERE MATCH (
keywords, title
)
AGAINST (
'%%%pottery%%'
)
ORDER BY score DESC


PHP


<?php
 MySQL_connect("xxxxxxxxxxxxxx", "xxxxxxxxxxxx", "xxxxxxxxxxxxx");
    MySQL_select_db("xxxxxxxxxxxxxxxxxx");
        $sql = " 
           SELECT directory. * ,
MATCH (
keywords, title
)
AGAINST (
'%%%pottery%%'
) AS score
FROM directory
WHERE MATCH (
keywords, title
)
AGAINST (
'%%%pottery%%'
)
ORDER BY score DESC
        ";
        $res = MySQL_query($sql);
?>


THanks

G
0
Comment
Question by:gabss
  • 6
  • 4
  • 2
  • +1
16 Comments
 
LVL 57

Expert Comment

by:Pete Long
ID: 9686182
Hi ninobennett,
do you have the plugin for exchange?? what do the veritas job logs tell you?? do you have the open file option installed

Cheers!
0
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9686216
run youre query like this and you can see the error wich is occuring:
$res = mysql_query($sql , $connection) or die("<b>Query Failed</b><br>\n".$sql."<br>\n".mysql_errno().": ".mysql_error());
0
 
LVL 1

Author Comment

by:gabss
ID: 9686240
it returns only " Query Error "

nowt else....

any other help ?????????

and Petelong what u on about ?


G
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 6

Expert Comment

by:DoppyNL
ID: 9686286
strange that it returns " Query Error ", as that is not in the code....

try this one:
$res = mysql_query($sql) or die("<b>Query Failed</b><br>\n".$sql."<br>\n".mysql_errno().": ".mysql_error());

if still no result try
print($sql);
to check if the sql is correct in PHP (some string parsing might make the sql incorrect).

you can also try to put your sql on a single line:
$sql = "SELECT directory. * , MATCH (keywords, title) AGAINST ('%%%pottery%%') AS score FROM directory WHERE MATCH (keywords, title ) AGAINST ('%%%pottery%%') ORDER BY score DESC";
0
 
LVL 17

Expert Comment

by:Squeebee
ID: 9690780
You can also drop the % symbols unless you are really searching for a literal % symbol, in which case you should escape it with \%
0
 
LVL 1

Author Comment

by:gabss
ID: 9693659
DoppyNL

Thanks this works BUT:

$sql = "SELECT directory. * , MATCH (keywords, title) AGAINST ('%%%pottery%%') AS score FROM directory WHERE MATCH (keywords, title ) AGAINST ('%%%pottery%%') ORDER BY score DESC";


i have new BIG BIG problem with it....

If one row in db contains the word "pottery" it return it no problem.....

BUT

If 2 rows in db contain the wor "pottery" it return nothing

Any ideas


Thanks

G
0
 
LVL 17

Expert Comment

by:Squeebee
ID: 9693864
Did you try dropping all those % symbols?
0
 
LVL 1

Author Comment

by:gabss
ID: 9693948
yep tried that ???

Same problem ???

im lost...

please help ???

G
0
 
LVL 17

Expert Comment

by:Squeebee
ID: 9693999
How many rows are in the table? I term that appears in too many rows is considered a stop-word and is not searched against, since too large a percentage of rows will be returned.
0
 
LVL 1

Author Comment

by:gabss
ID: 9694029
only 4 ....

i'll add a load now and see

cheers
0
 
LVL 1

Author Comment

by:gabss
ID: 9694064
yeh it sort of works....

BUT

im doing a niche directory so 10 sites might have the same keywords..... out of 20 ....

Is there a work around ?


Thanks again

G

0
 
LVL 1

Author Comment

by:gabss
ID: 9694088
it only work with 4 lettered words ?

can it do 3 ??

thanks again

G
0
 
LVL 17

Accepted Solution

by:
Squeebee earned 40 total points
ID: 9694529
Three letter words are too short, it is possible to change the setting and recompile if needs be, you can also use the IN BOOLEAN MODE searching to get around the half row limits and 3 word constraints.
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 11145088
Hello this question has been open a while please take the time to come back and clean it up.

Closing Questions
http://www.experts-exchange.com/help.jsp#hs5


Best Wishes

Pete
www.petenetlive.com
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question