1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

why mysql_insert_id() didnt return last inserted id?

Discussion in 'PHP' started by rajnikant, Apr 1, 2008.

  1. #1
    Hello,

    I am executing the insert query in mysql database through php script, But i am unable to get the last insert id .
    I had used the syntax mysql_insert_id();

    anybody knows whats the problem and whats the solution?

    thanks
    raj
     
    rajnikant, Apr 1, 2008 IP
  2. singh.ajit05

    singh.ajit05 Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi rajnikant..
    May be your placement is being wrong.......
    It will return last inserted id from database, so please use it just after a insert query execution...like this

    $sql="insert into ............";
    mysql_query($sql);
    $getid=mysql_insert_id();

    echo $getid;

    I think .............you got you solution...
     
    singh.ajit05, Apr 2, 2008 IP