Problem with mysql_insert_id

Discussion in 'PHP' started by kmap, Dec 8, 2007.

  1. #1
    1. insert query
    2. mysql_insertid in $id
    3. select query
    if i donot perform 3. then i get $id
    otherwise not



    code for insert query


    $id = mysql_insert_id(); ///2.

    $query = str_replace("[x]", $CONF["MYSQL_DATABASE_TABLES_PREFIX"],"SELECT latitude,longitude FROM `[x]zipcode` WHERE `zip_code`=".$_SESSION["REGISTER"]["zipcode"]." limit 1");


    $result=mysql_query($query);
     
    kmap, Dec 8, 2007 IP
  2. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    WHat exactly is your problem here?

    mysql_insert_id() returns the last auto increment value, is it not returning this correctly?
    If so make sure you are actually using auto increment.

    Hope this helps
     
    tonybogs, Dec 9, 2007 IP