gabss
asked on
php sql full text
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("xxxxxxxxxxx xxx", "xxxxxxxxxxxx", "xxxxxxxxxxxxx");
MySQL_select_db("xxxxxxxxx xxxxxxxxx" );
$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
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("xxxxxxxxxxx
MySQL_select_db("xxxxxxxxx
$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
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."<b r>\n".mysq l_errno(). ": ".mysql_error());
$res = mysql_query($sql , $connection) or die("<b>Query Failed</b><br>\n".$sql."<b
ASKER
it returns only " Query Error "
nowt else....
any other help ?????????
and Petelong what u on about ?
G
nowt else....
any other help ?????????
and Petelong what u on about ?
G
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."<b r>\n".mysq l_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";
try this one:
$res = mysql_query($sql) or die("<b>Query Failed</b><br>\n".$sql."<b
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";
You can also drop the % symbols unless you are really searching for a literal % symbol, in which case you should escape it with \%
ASKER
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
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
Did you try dropping all those % symbols?
ASKER
yep tried that ???
Same problem ???
im lost...
please help ???
G
Same problem ???
im lost...
please help ???
G
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.
ASKER
only 4 ....
i'll add a load now and see
cheers
i'll add a load now and see
cheers
ASKER
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
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
ASKER
it only work with 4 lettered words ?
can it do 3 ??
thanks again
G
can it do 3 ??
thanks again
G
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello this question has been open a while please take the time to come back and clean it up.
Closing Questions
https://www.experts-exchange.com/help.jsp#hs5
Best Wishes
Pete
www.petenetlive.com
Closing Questions
https://www.experts-exchange.com/help.jsp#hs5
Best Wishes
Pete
www.petenetlive.com
do you have the plugin for exchange?? what do the veritas job logs tell you?? do you have the open file option installed
Cheers!