Welcome Guest, Not a member yet? Register   Sign In
Update throwing MySQL error
#1

[eluser]welzie[/eluser]
I don't understand why this update statement won't work when executed in code. If I copy the query into an sql tool and remove the backticks it works. Any ideas? Thanks for reading.

Code that throws the error.
Code:
$this->db->update('brandRecaps', $brandRecap, 'id= '.$id);

Quote:Error Number: 1064

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 '3' at line 1

UPDATE `brandRecaps` SET `samplesDistributed` = '1', `bottlesSold` = '2', `bottlesUsed` = '3', `itemSalePrice` = '4', `itemRegularPrice` = '5', `bottlesPriorToTasting` = '6', `facingsForBrand` = '7', `accountGoodFitForBrand` = 'a', `consumerRating` = 'a', `fbLikeOrDislike` = 'a', `fbMotivatesToPurchase` = 'a', `fbFavoriteDrinkOfBrand` = 'a', `fbDoesAccountSupportBrand` = 'a', `fbObstacles` = 'a', `fbAdditionalFeedback` = 'a', `brandId` = '3', `recapId` = '8' WHERE `id=` 3

Filename: W:\servers\php-frameworks\codeIgniter-2.1.0\system\database\DB_driver.php

Line Number: 330

database config
Code:
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;




Theme © iAndrew 2016 - Forum software by © MyBB