0

Don't know how to say this, but I have used mysql_insert_id() for many many years. Recently I included it in my web applications and worked well, I have successfully received 50 transactions and was happy. All of a sudden all my transactions are coming in with ids equal 0, I Google'd around and read something about persistent connection being set to true? I just want me to make sure I give the right info to my network server guy, God knows, whenever something changes, they don't let me know, I only find out when my code all of a sudden breaks.

is there another function to use other than mysql_insert_id() in my PHP/MySQL code? just for those who want to see code here is what i have: I am not including "id" as it is "auto increment not null primary key, etc"

    <?php
$db_host2 = 'localhost';
$db_user2 = 'different';
$db_pass2 = 'different';
$db_name2 = 'different';
$conn2 = &NewADOConnection('mysqlt');
$db2 = $conn2->Connect($db_host2,$db_user2,$db_pass2,$db_name2);
if($conn2->isConnected()==false)
   die("Could not connect to the database.  Please try again in the next few minutes.");   


    $db_host = 'localhost';
    $db_user = 'admin';
    $db_pass = 'pass';
    $db_name = 'name';
    include_once('adodb/adodb.inc.php');
    define('ADODB_FETCH_ASSOC',2);
    $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    $conn = NewADOConnection('mysqlt');
    $db = $conn->Connect($db_host,$db_user,$db_pass,$db_name);
    if($conn->isConnected()==false)
       die("Could not connect to the database.  Please try again in the next few minutes.");
        $q="insert into tableA(name,address,phone) values ('','','')"
        $rs=$conn->execute($q);
        $myid=mysql_insert_id();
        ?>
4

1 回答 1

0

您只需要 1 个配置示例:

// database config
$DB_TYPE        = "mysql";
$DB_HOST        = "xxxxx";
$DB_USER        = "xxxx";
$DB_PWD     = "xxxx";
$DB_NAME        = "xxx";

然后将最后一个插入 ID 用于:

$db->Insert_ID
于 2013-04-01T01:47:42.043 回答