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
    218
    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
    218
    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,040
    Thanks
    151
    Thanked 278 Times in 206 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.
    Hidden Hit Counter My forum signature is under construction.

  6. #5
    TopDogger's Avatar
    TopDogger is online now Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    2,240
    Thanks
    293
    Thanked 767 Times in 562 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.
    "It's inexcusable for scientists to torture animals; let them make their experiments on journalists and politicians." -Henrik Ibsen

Similar Threads

  1. [WTS] US Golf Courses Database (MySQL) – 19,168 Records
    By yangyang in forum Content
    Replies: 0
    Last Post: 22 December, 2010, 14:16 PM
  2. Replies: 0
    Last Post: 19 November, 2010, 01: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, 02:20 AM
  5. How to Optimize a MySQL Database
    By Tom in forum Databases
    Replies: 0
    Last Post: 23 December, 2008, 09: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
  •