php插入mysql数据返回id的方法
如下所示:
<?php $dbh = mysql_connect('localhost','root','root'); mysql_select_db('pkbk'); $query = "insert intov9_admin_role_priv(roleid, m, c, a, `data`, siteid) values (12, 'huiben','huiben', 'hbprop_add', '', 1)"; $res = mysql_query($query, $dbh); //"获取刚才插入的id,表需要设置主键自增" echo "ID of last inserted record is: " .mysql_insert_id(); $query = "select max(roleid) fromv9_admin_role_priv"; $res = mysql_query($query, $dbh); $err = mysql_error(); if($err){ echo "发生错误,请通知管理员"; } $row = mysql_fetch_row($res); echo "未来您使用的号码为:".$row[0]; ?>
匹克系统应用:
$query = " INSERT INTOpkbk.v9_member (phpssouid, username, password, encrypt, nickname, regdate,lastdate, regip, lastip, loginnum, biaoshi, planid, email, groupid, areaid,amount, point, modelid, message, islock, vip, overduedate, siteid, connectid,`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, '[email protected]', 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();
相关推荐
yifangs 2020-10-13
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23