Results 1 to 5 of 5

Thread: MySQL database update

  1. #1
    proweb's Avatar
    proweb is offline Joomla Developer
    Join Date
    Jan 2010
    Posts
    217
    Thanks
    4
    Thanked 24 Times in 23 Posts

    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
    dtkguy's Avatar
    dtkguy is offline Still Learnin'
    Join Date
    Dec 2008
    Posts
    391
    Thanks
    7
    Thanked 164 Times in 108 Posts
    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. Thanked by:

    Aziz (21 May, 2010)

  4. #3
    proweb's Avatar
    proweb is offline Joomla Developer
    Join Date
    Jan 2010
    Posts
    217
    Thanks
    4
    Thanked 24 Times in 23 Posts
    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

  5. #4
    Andy101's Avatar
    Andy101 is online now Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,313
    Thanks
    178
    Thanked 309 Times in 236 Posts
    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.
    Otaku CMS - Import a WordPress blog and manage your site using single-page App technology

  6. #5
    TopDogger's Avatar
    TopDogger is offline Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    3,106
    Thanks
    350
    Thanked 919 Times in 703 Posts
    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, 10: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
  •