After update.php I got this error:
user warning: 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 's')' at line 1 query: INSERT INTO location_country (code, name) VALUES ('bs', 'Bahama's') in /sites/all/modules/location/location.install on line 1217.

Comments

scjv’s picture

I have the same error:

  • user warning: 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 's')' at line 1 query: INSERT INTO dp_location_country (code, name) VALUES ('bs', 'Bahama's') in /var/www/html/modules/location/location.install on line 1217.
  • warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/html/-SITE-/update.php on line 173.
  • warning: Invalid argument supplied for foreach() in /var/www/html/-SITE-/update.php on line 340.
didier misson’s picture

Hello
Same error : update with Drush 6.0

Refreshing update status information ...
Done.
site_offline was set to "1".                                                                                                                                                                       [success]

 Name                 Installed Version  Proposed version  Message                
 GMap (gmap)          6.x-2.0-beta3      6.x-2.0-beta5     Mise à jour disponible 
 Location (location)  6.x-3.2            6.x-3.3           Mise à jour disponible 


Update information last refreshed: mar, 24/09/2013 - 19:15
Code updates will be made to the following projects: GMap Module [gmap-6.x-2.0-beta5], Location [location-6.x-3.3]

Note: A backup of your project will be stored to backups directory if it is not managed by a supported version control system.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue with the update process? (y/n): y
Project gmap was updated successfully. Installed version is now 6.x-2.0-beta5.
Backups were saved into the directory /root/drush-backups/dm_epa4/20130924171518/modules/gmap.                                                                                                     [ok]
Project location was updated successfully. Installed version is now 6.x-3.3.
Backups were saved into the directory /root/drush-backups/dm_epa4/20130924171518/modules/location.                                                                                                 [ok]
'all' cache was cleared in self                                                                                                                                                                    [success]
You have pending database updates. Run `drush updatedb` or visit update.php in your browser.                                                                                                       [warning]
 Location  6310  Adds the Country code to name table "location_country".  It is created from the included array country array.


Do you wish to run all pending updates? (y/n): y
Executing location_update_6310                                                                                                                                                                     [success]

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 'Ivoire')' at line 1                          [warning]
query: INSERT INTO drup_epalocation_country (code, name) VALUES ('ci', 'Côte d'Ivoire') database.mysqli.inc:134

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 'océan Indien')' at line 1                   [warning]
query: INSERT INTO drup_epalocation_country (code, name) VALUES ('io', 'Territoire britannique de l'océan Indien') database.mysqli.inc:134

'all' cache was cleared in self                                                                                                                                                                    [success]
Finished performing updates.                                                                                                                                                                       [ok]
site_offline was set to "0".  

Thanks

LittleRedHen’s picture

Same error here.

The problem seems to be that the location_update_6310() function in location.install should return an array, but doesn't actually return anything. The function does execute successfully, so this can be safely ignored.

Adding return array(); as the last line of that function makes the warning messages go away.

urlisse’s picture

Version: 6.x-3.3 » 6.x-3.x-dev
StatusFileSize
new795 bytes

I believe the update function should look like something closer to this:

function location_update_6310() {
    //Create the new table
    $schema = location_schema() ;
    db_create_table($ret, 'location_country', $schema['location_country']);

    //Fill it.
    $sql = "INSERT INTO {location_country} (code,name) VALUES ('%s', '%s') ";
    $countries = location_get_iso3166_list();
    foreach($countries as $code => $name){
        db_query($sql, array($code, $name));
    }   
}   

This should avoid the syntax error as well as database injection errors... I also brutally removed a few lines which appeared to add the country code and name to an array for no reason...

I've attached a patch. Please note that I am not a maintainer of this module. Apply at your own risks.

urlisse’s picture

Please disregard the previous patch, which was untested and had a syntax error. Here's a replacement.

urlisse’s picture

Issue summary: View changes

Update to delet the internal path where modules are stored.

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing old D6 issues as D6 is end of life