SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mysql - getting id while updating mysql_insert_id does not work

    Hi all

    I'm updating a row and I need to get the id for that row (update is done by using a different field).

    I tried to use mysql_insert_id and get 0 all the time and then I checked the Mysql online manual and saw that this function cannot get the id if does not change it.

    Anyone has any ideas?

    Here goes my code:

    PHP Code:
    $kayit_iptal_onayla =    "update adresler set ".
                            "mevcut_durum='0'".
                            "where e_posta='$tey'";
                        
    if (mysql_query($kayit_iptal_onayla)){ ?>

    <?php
    }
    else { 
    ?>

    <?php
        
    echo(mysql_error()); 
    //end if 

    $adresler_id=mysql_insert_id();
    Thanks in advance.
    Last edited by EvrimK; Jan 28, 2003 at 06:14.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I think you're going to have to run a separate query to get the ID.

    One thing to watch though ... does the e_posta field allow duplicate entries? You can check this on the UPDATE call by using the mysql_affected_rows( ) function.
    Ian Anderson
    www.siteguru.co.uk


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
  •