CMS MADE SIMPLE FORGE

Company Directory

 

[#4198] insert company fails if lat long is not entered

avatar
Created By: Tony Guadagno (tguadagno)
Date Submitted: Thu Oct 15 23:41:46 -0400 2009

Assigned To:
Version: 1.4
CMSMS Version: None
Severity: Major
Resolution: Works For Me
State: Closed
Summary:
insert company fails if lat long is not entered
Detailed Description:
Hi,
I installed on cmsms 1.66  When i tried to add a company, it says it suceeds,
but there is no company in the table.  I added some debug and found this

QUERY: INSERT INTO cms_module_compdir_companies (company_name, address,
telephone, fax, contact_email, website, details, picture_location,
logo_location, create_date, modified_date, status, latitude, longitude) VALUES
('Air East
Airways','','631-756-5500','631-756-5527','maureen@aireast.com','www.aireast.com','test','','','2009-10-15
22:30:22','2009-10-15 22:30:22','published','','')
ERROR: Data truncated for column 'latitude' at row 1

i then tried to add and put 0.0 in both lat and long  and found that the company
added properly.

seems like a bug


History

Comments
avatar
Date: 2010-08-25 11:09
Posted By: John Beatrice (mww)

A colleague of mine can also confirm this bug and found the below fix resolves
it.

It looks like mySQL 5.x does not like an empty string for numeric types. It
needs to give NULL instead.

Using PHP 5.2.3, mySQL 5.0.7, CMSMS 1.8.2 and Company Directory 1.6.5

In file action.add.company.php around lines 46 to 56:

Replace this:
$latitude = '';
if (isset($params['latitude']))
{
	$latitude = $params['latitude'];
}

$longitude = '';
if (isset($params['longitude']))
{
	$longitude = $params['longitude'];
}

With this:

$latitude = NULL;
if (isset($params['latitude']) && is_numeric($params['latitude']))
{
$latitude = $params['latitude'];
}

$longitude = NULL;
if (isset($params['longitude']) && is_numeric($params['longitude']))
{
$longitude = $params['longitude'];
}

OR this to be more be more concise:

$latitude = ( floatval($params['latitude']) ? floatval($params['latitude']) :
NULL );
$longitude = ( floatval($params['longitude']) ? floatval($params['longitude']) :
NULL );



      
avatar
Date: 2010-08-25 11:16
Posted By: Robert Campbell (calguy1000)

I'm on mysql 5.0 and have no problems.
      
avatar
Date: 2011-05-06 08:37
Posted By: Wes Funderberg (wfunderberg)

I am having the same issue. 

CMS Version 1.9.4.1

CompanyDirectory 1.8.3

PHP 5.2.6 

MySQL 5.5.10 
      
avatar
Date: 2011-05-06 08:44
Posted By: Wes Funderberg (wfunderberg)

Please add the above fix by John Beatrice to the code core as this fixes the
problem.
      
Updates

Updated: 2011-12-22 22:29
cmsms_version_id: => -1
state: Open => Closed

Updated: 2010-08-25 11:16
resolution_id: => 11