$sql_i="insert into tb_news(username,content,time,message) values('{$_SESSION['username']}','{$_POST['content']}','{$time}',0)"; $result_i = $db->mysqli->query($sql_i); $getID = $db->mysqli->insert_id;
追答
$conn = new mysqli("127.0.0.1","root","","database") or die("数据库连接超时!"); $sql_i="insert into tb_news(username,content,time,message) values('{$_SESSION['username']}','{$_POST['content']}','{$time}',0)"; $getID=mysqli_insert_id($conn); 括号里面的一定要是数据库连接而不是执行结果 echo $getID;