Unknown column Error on Insert

SugarCRM is generating Wrong Query while insert. in the following scenario.

we have accounts module with standard and custom fileds.

SugarCRM is generating Query like

Query with comment
INSERT INTO accounts (id,name, [quote](all standard fields)[/quote] , services_needed_c ,

VALUES (’’,’’,’’,’’)…

Observe : services_needed_c is in accounts_cstm table but it tries to insert in accounts table.

such that i get MySQL error 1054: Unknown column error.

Please help !! ( I did repair and rebuid but no luck )
How to resolve this issue.

Do you have SugarCRM or SuiteCRM? (note that this is the SuiteCRM Forum!)

In any case you should specify at least the version and the environment.

In addition you should specify if there are some custom developments and any other information that may be relevant to help issuing a diagnosis.

Have you checked the Apache, PHP and SugarCRM logs? Do they report any kind of errors. Usually they are a good starting point.

Have you set the right permissions of the whole directory structure as well as in config.php?

I am using SugarCRM Version 6.5.18 (Build 1110)

Web Server Config

Apache/2.2.15 (CentOS)
Database client version: libmysql - 5.1.73
PHP extension: mysqli

PHP Version : PHP Version 5.5.25

I get errors in sugarcrm log file.

permissions in config.php is below

array (
‘dir_mode’ => 02775,
‘file_mode’ => 0775,
‘user’ => ‘apache’,
‘group’ => ‘apache’,


$sugar_config[‘default_permissions’][‘user’] = ‘apache’;
$sugar_config[‘default_permissions’][‘group’] = ‘apache’;

in case of development we have created custom modules are using rest API TO manipulate data.

Errors are loged in SugarCRM log

MySQL error 1054: Unknown column <any cudtom field.

Appreciate your help