Jump to content

Search Error


Miyk

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
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.