rhyspaterson Posted July 9, 2007 Share Posted July 9, 2007 Hey guys, Receiving the following syntax error: Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: syntax error at or near "user" LINE 1: UPDATE user SET name = 'Joe Blogs', password = 'ck2007' ... ^ in /var/www/menu/client/form/process.php on line 435 The command being used is: $result = pg_exec($dbconn, "UPDATE user SET name = '$username', password = '$userPassword' WHERE id = '$userID'"); All the variables are fine, just not sure what's wrong with the statement.. any suggestions? Ta! Link to comment https://forums.phpfreaks.com/topic/59037-solved-php-sql/ Share on other sites More sharing options...
rhyspaterson Posted July 9, 2007 Author Share Posted July 9, 2007 edit: table name was wrong >_> Link to comment https://forums.phpfreaks.com/topic/59037-solved-php-sql/#findComment-293058 Share on other sites More sharing options...
GingerRobot Posted July 9, 2007 Share Posted July 9, 2007 User is a reserved word in PostgreSQL. Having only ever used mysql, i cant guarantee it, but i would guess the quickfix is to use backticks (`) around your field names: $result = pg_exec($dbconn, "UPDATE `user` SET `name` = '$username', `password` = '$userPassword' WHERE id = '$userID'"); The proper solution is to not use reserved words as table or column names. Link to comment https://forums.phpfreaks.com/topic/59037-solved-php-sql/#findComment-293059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.