Set Cookie with 2nd Primary key???

Discussion in 'PHP' started by Gazz1982, Jun 24, 2007.

  1. #1
    I'm desinging a database as part of my archaeology masters in GIS

    I've been teaching myself apache server, php, mysql, html for the last month and now i have got stuck:

    The database has an auto incremented ID number how ever when i update the row each row gets written over therefore i want to set th primary key to the ID as well as a cookie - any ideas on how to do this?

    so far i have

    <?php
    setcookie(time()+3600);

    ?>


    This needs to be stored and remembered on each page so i assume i will need some kind of sql I have to tell the db that the newly created id no. is linked to the cookie so that all information from that user stays in the single row and does not over right any of the other data

    Thanks for you help

    Gary Nobles
     
    Gazz1982, Jun 24, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    im not quite sure that i understand the situation. though instead of inserting a new row you might want to look into the mysql REPLACE syntax.
    http://dev.mysql.com/doc/refman/4.1/en/replace.html

    and ther is always mysql_insert_id() which will return the last auto_incremented id generated in the database.
     
    ansi, Jun 24, 2007 IP
  3. chuckd1356

    chuckd1356 Active Member

    Messages:
    770
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Or check out the update syntax. All those cookies aren't necessary.
     
    chuckd1356, Jun 24, 2007 IP