Jump to content


Photo

Search Error


  • Please log in to reply
3 replies to this topic

#1 Miyk

Miyk
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 22 July 2006 - 07:28 PM

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


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


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

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";

Any help would be greatly appreciated thanks! ???

-Mike

#2 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 22 July 2006 - 10:45 PM

where did you get that MATCH() function? I can't find it in the mysql manual:

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



#3 Miyk

Miyk
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 23 July 2006 - 08:00 PM

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:

http://dev.mysql.com...strictions.html

Thanks for the help! :)

-mike


#4 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 23 July 2006 - 08:18 PM

$fields is empty, as deducted from your errormessage:

from news_stories where MATCH() AGAINST

Read up on mysql's fulltext searching.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users