mysql_insert_id()突然停止工作

时间:2022-10-16 03:58:42

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.

不知道该怎么说,但我已经使用了mysql_insert_id()很多年了。最近我把它包含在我的网络应用程序中并运作良好,我已成功收到50笔交易,并且很高兴。突然之间,我的所有交易都是在等于0的情况下进行的,我谷歌周围读了一些关于持久连接被设置为真的东西?我只是想让我确保向网络服务器人员提供正确的信息,天知道,每当有什么变化,他们都不让我知道,我只知道我的代码突然间断了。

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 / MySQL代码中还有另外一个函数可以使用mysql_insert_id()吗?只是为了那些想要看到代码的人是我拥有的:我不包括“id”,因为它是“自动增量非空主键等”

    <?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();
        ?>

1 个解决方案

#1


0  

You just need 1 configuration example :

您只需要1个配置示例:

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

then use last insert ID for :

然后使用最后一个插入ID:

$db->Insert_ID

#1


0  

You just need 1 configuration example :

您只需要1个配置示例:

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

then use last insert ID for :

然后使用最后一个插入ID:

$db->Insert_ID