Jump to content

Archived

This topic is now archived and is closed to further replies.

Miyk

Search Error

Recommended Posts

Hello I am having a problem with a search function written in PHP / MySql, here is there error:

[color=red]
MYSQL ERROR in dbobj_count: You have an error in your SQL syntax near ') AGAINST('test')' at line 1
Query: select count(*) from news_stories where MATCH() AGAINST('test')MYSQL ERROR in dbjobj_join: You have an error in your SQL syntax near ') AGAINST ('test') as cms_score from news_stories where MATCH() AGAINST ('test')' at line 1
Query: select *, MATCH() AGAINST ('test') as cms_score from news_stories where MATCH() AGAINST ('test') LIMIT 0, 9999999999[/color]

I believe the error lies in here, but i can't seem to figure it out, the site has been ported over from other hosting, and i believe the version of mySql may be a bit differant, can it be a quote issue, since i believe differant versions of mysql are sensitive to that sort of syntax? :

[code]
function CMSTextSearchResults($format,$table = null) {
$offset = (is_integer($_REQUEST['start']) ? $_REQUEST['start'] : 0);
$limit = (is_integer($_REQUEST['num']) ? $_REQUEST['num'] : 9999999999);

if ($table == null) {
$tables = array_keys($GLOBALS['TEMPLATE']);
$tables[] = 'cms_content';
} else
$tables = array($table);

$results = array();
foreach ($tables as $table) {
$fields = join(",",_fulltextfields($table));
$returnStr = '';

// find number of rows total
$count_qry = "select count(*) from $table ".
"where MATCH($fields) AGAINST('$_REQUEST[query]')";
$GLOBALS['_numresults'] += dbobj_count($count_qry);

// just return the subset asked for
$qry = "select *, MATCH($fields) AGAINST ('$_REQUEST[query]') as cms_score ".
"from $table where ".
"MATCH($fields) AGAINST ('$_REQUEST[query]') ".
"LIMIT $offset, $limit";
[/code]

Any help would be greatly appreciated thanks! ???

-Mike

Share this post


Link to post
Share on other sites
where did you get that MATCH() function? I can't find it in the mysql manual:

http://dev.mysql.com/doc/refman/5.0/en/

Share this post


Link to post
Share on other sites
I myself didn't write the code, It was done a long time ago i guess, and the developer isn't available to help for some reason  :-\ , but i did find the Match() function mentioned in the manual here:

[url=http://dev.mysql.com/doc/refman/4.1/en/fulltext-restrictions.html]http://dev.mysql.com/doc/refman/4.1/en/fulltext-restrictions.html[/url]

Thanks for the help! :)

-mike

Share this post


Link to post
Share on other sites
$fields is empty, as deducted from your errormessage:

[b]from news_stories where [u]MATCH()[/u] AGAINST[/b]

Read up on mysql's fulltext searching.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.