Results 1 to 5 of 5

Thread: MySQL database update

  1. 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.

    Code:
    $query    = "INSERT INTO users (id, name, username, email, password , img)
            VALUES ('$new_id', '$name', '$username', '$email', '$password', '$image_name' );";
    How can I do only update the new info and keep the rest? Please help me with this!

    Thanks a lot!
    Find Best Web Hosting Service. It's good or bad host? - JustHost Review
    Download free joomla themes for version 1.5 and 1.6

  2. #2
    You need to update the specific dataset:

    Code:
    UPDATE `users` SET `img` = '$image_name' WHERE `id` = '$userID'
    where the $userID is that users specific id number, or whatever you have it set as.

  3. Thanks for your replay! This is working perfectly!
    Find Best Web Hosting Service. It's good or bad host? - JustHost Review
    Download free joomla themes for version 1.5 and 1.6

  4. #4
    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.

  5. #5
    Quote Originally Posted by Andy101 View Post
    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.
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin


Similar Threads

  1. [WTS] US Golf Courses Database (MySQL) – 19,168 Records
    By yangyang in forum Content
    Replies: 0
    Last Post: 22 December, 2010, 15:16 PM
  2. Replies: 0
    Last Post: 19 November, 2010, 02:51 AM
  3. Backup of Mysql database using PhpMyAdmin
    By mega in forum Databases
    Replies: 2
    Last Post: 14 May, 2009, 09:06 AM
  4. How to Repair a MySQL Database
    By Will.Spencer in forum Databases
    Replies: 19
    Last Post: 13 January, 2009, 03:20 AM
  5. How to Optimize a MySQL Database
    By Tom in forum Databases
    Replies: 0
    Last Post: 23 December, 2008, 10:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •