MySQL database update
Hello guys, sorry for the newbie question, but I need some help with this:
I have an existing database for registered users.
Each user already have the following info stored in the database: id, name, username, email, password.
I have added a new row and I want to store image names in database. I want that user to be able to upload image to the profile, but store it into the database.
With the following query the system is creating a new user, but I want only to update the 'img' field.
How can I do only update the new info and keep the rest? Please help me with this!
$query = "INSERT INTO users (id, name, username, email, password , img)
VALUES ('$new_id', '$name', '$username', '$email', '$password', '$image_name' );";
Thanks a lot!:thumbsup:
You need to update the specific dataset:
where the $userID is that users specific id number, or whatever you have it set as.
UPDATE `users` SET `img` = '$image_name' WHERE `id` = '$userID'
Thanks for your replay! This is working perfectly!
Another thing to pick up on here is that dtkguy includes the tick marks in his/her MySQL query. This is important for security reasons and shows a level of professionalism in delivering this solution.
I'm curious. How does that improve security? Tick marks or single quotes are only required for string values, so the statements work either way. I've always looked at it as two methods to work with MySQL syntax.
Originally Posted by Andy101