This article mainly introduces the PHP insert MySQL data return ID method, has a certain reference value, now share to everyone, the need for friends can refer to
As shown below:
<?PHP$DBH = mysql_connect (' localhost ', ' root ', ' root '); mysql_select_db (' pkbk '); $query = "Insert Intov9_admin_role_ Priv (Roleid, M, C, a, ' data ', SiteID) VALUES (n, ' huiben ', ' huiben ', ' hbprop_add ', ', 1) '; $res = mysql_query ($query, $DBH );//"Gets the ID just inserted, the table needs to set the primary key auto-increment" echo "ID of last inserted record is:". mysql_insert_id (); $query = "Select Max (Roleid) fromv9_adm In_role_priv "; $res = mysql_query ($query, $dbh); $err = Mysql_error (); if ($err) { echo" has an error, notify the administrator ";} $row = Mysql_fetch_row ($res); echo "The number you use in the future is:". $row [0];? >
Pico System Applications:
$query = "INSERT intopkbk.v9_member (phpssouid, username, password, encrypt, nickname, Regdate,lastdate, Regip, Lastip, L Oginnum, Biaoshi, Planid, email, groupid, Areaid,amount, point, ModelID, message, Islock, VIP, Overduedate, SiteID, Connec Tid, ' from ', Mobile, yey, YEYBJ, Sleeptime, Waketime, Cardno, Zentime, Zencount,is_js, Bsount) "." VALUES (1, ' LBG ', ' 9f575f22246a1a5fb38e1846bb0ec964 ', ' Ptseba ', ', ' 1384397338, 1403544894, ' 221.199.6.231 ', ' 118.112.20.103 ', 0, ', 0, ' nxnet123@qq.com ', 2, 0, 0, 0, 10,0, 0, 0, 0, 1, ' a74eecdfa5a22c81c05ed49e7cf9224d ', ' qq ', ', ",", 0, 0, ", 0, 0, 0, 0)"; $number = $mydb->sql_query ($query); echo "ID of last inserted Recordis:". mysql_insert_id ();
The above is the whole content of this article, thank you for reading. For more information, please pay attention to topic.alibabacloud.com!