Page 1 of 1

[SOLVED] Search module re-index gives SQL error

Posted: Thu Feb 12, 2015 2:20 pm
by webform
When i try to reindex all content in Search module i get this SQL error:

Code: Select all

ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE active=1' at line 5
Cms Version: 1.11.12
phpversion: 5.4.37
Server Db Type: MySQL (mysql)
Server Db Version: 5.1.63

My local MAMP installation does not give this error! But it's also a newer version of PHP and MySQL:

phpversion 5.6.2
Server Db Type: MySQL (mysql)
Server Db Version: 5.5.38

So is it my web host's PHP and MySQL versions the problem?

Re: Search module re-index gives SQL error

Posted: Thu Feb 12, 2015 3:11 pm
by calguy1000
I checked. That code is not coming from anything in the CMS core.
It's probably a module.

You will have to do more digging, and isolate the problem to the specific module.

Re: Search module re-index gives SQL error

Posted: Thu Feb 12, 2015 3:51 pm
by webform
I've narrowed it down to the FAQ module!

Code: Select all

	function SearchReindex(&$module)
	{
		$db = cmsms()->GetDB();
		$query = "SELECT
								entry_id, question, answer
							FROM
								" . cms_db_prefix() . "module_gbook_entries,
							WHERE
								active=1";
		$result = $db->Execute($query);
		if ( $result && $result->RecordCount() > 0 )
		{
			while ( $row=$result->FetchRow() )
			{
				$module->AddWords($this->GetName(), $row['entry_id'], 'entry', $row['question'] . ' ' . $row['answer']);
			}
		}
		if ( !$result )
		{
			echo 'ERROR: ' . mysql_error();
			exit();
		}
	}
I've changed module_gbook_entries to module_faq_entries as it was wrong but it still gives an error!

Re: Search module re-index gives SQL error

Posted: Thu Feb 12, 2015 4:08 pm
by webform
It's solved now.

I've changed

Code: Select all

removed by moderator
It was a wrong call to table module_gbook_entries and stray comma making all the trouble.

Re: [SOLVED] Search module re-index gives SQL error

Posted: Thu Feb 12, 2015 4:12 pm
by paulbaker
Sounds like this should be raised as a bug please?
http://dev.cmsmadesimple.org/projects/faq
click Bug Tracker tab.

Re: [SOLVED] Search module re-index gives SQL error

Posted: Thu Feb 12, 2015 4:17 pm
by webform
Yes! I've already filed a bug report in the forge.