Jump to content


Function change from newuser to updateuser

  • Please log in to reply
1 reply to this topic

#1 genista

  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 04 September 2006 - 01:00 PM

Hi all,

I have a function that helps to create a new user, the query looks like so:

$query="INSERT INTO users (username, password, etc, etc) 

Now I need a function that updates the user details, so when I call update user it updates the database with all of the vlaues. The problem I have is that when I run this updateuser function in any of my scripta I get:

"Died inserting login info into db. Error returned if any: 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 '(username, password"

Off the following change:

$query="UPDATE users (username, password, etc, etc where username=$username) 

$username is defined in the script as I have already run a query to select * from the user table.

ANy ideas? (I hope it is a simple one)


#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 01:26 PM

Use this:
$query="UPDATE users (`username`, `password`, `etc, etc`) where `username`='$username'";
As the SQL query. password is a SQL keyword so MySQL is getting confused and so result in the above error. You should add backticks around the column names in your query, like I have done. This is prevent SQL from getting confused and is good practice to add backticks around column/table names in your SQL queries

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users