#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    6
    Rep Power
    0
    Hi all,

    I'm trying to figure out how to update a MySQL record (a single row) I cuurently have this but it isn't working... I'm just getting that error "0 is not a mysql result index...." or just the DIE result.

    mysql_db_query("guru", "INSERT INTO newslinks (clicks) values('$iClicks') WHERE id='$id'")
    or DIE("Unable to insert into database");

    $id is a value from an auto_increment col, so it might be "34" or something.

    Therefore I want a command to tell Mysql to go to the row with id number "34" and update the col on that row with $iClicks.

    Thanks heaps for your time,
    Billy

  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    "INSERT INTO newslinks (clicks) values('$iClicks') WHERE id='$id'"


    it should be:
    "INSERT INTO newslinks (clicks) values('$iClicks') WHERE id=$id"

    no need to put single quote for auto increment field.

    also make sure that your field names are correct..(ie, clicks)

    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited June 03, 2000).]
  4. #3
  5. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    The proper syntax for what you are trying to do is:

    update newslinks set clicks='$iClicks' where id=$id

    Insert is for new records.

Similar Threads

  1. Problems updating a field in a MySQL db
    By ez_d_ in forum PHP Development
    Replies: 1
    Last Post: November 3rd, 2003, 10:21 PM
  2. Problems updating a field in a MySQL db
    By ez_d_ in forum PHP Development
    Replies: 0
    Last Post: October 31st, 2003, 04:03 PM
  3. Problems updating a field in a MySQL db
    By ez_d_ in forum PHP Development
    Replies: 2
    Last Post: October 30th, 2003, 09:23 PM
  4. Replies: 4
    Last Post: June 12th, 2002, 10:24 AM
  5. updating MySQL automatically?
    By piksimoon in forum MySQL Help
    Replies: 2
    Last Post: July 30th, 2001, 12:47 PM

IMN logo majestic logo threadwatch logo seochat tools logo