Jump to content

[SOLVED] PHP + SQL


rhyspaterson

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.