php - I can't get the ID variable using mysqli_insert_id
问题描述
I'm trying to execute this sql query but it doesn't insert in the correct ID. I'm trying getting the last ID using mysqli_insert_id but without result. Thanks for the help!
$sql = "insert into desechados
(rutrep, rutempr, nombreusu, apematusu,
apepatusu, nombempr, giroempr, direempr,
corrusua, numeusua)
select rutrepr, rutempr, nombusua, apematus,
apepatus, nombempr, giroempr, direempr,
corrusua, numeusua
from usuario
where rutrepr='".$_SESSION['rutrep']."'";
if(mysqli_query($con,$sql)){
$last_id = mysqli_insert_id($con);
}
$razonrechazo = $_POST['oculto'];
$sql1 = "insert into desechados (razonrechazo) values ('$razonrechazo') where (iddesechados=".$last_id.") ";
mysqli_query($con, $sql1);
解决方案
推荐阅读
- xcode - 如何在 Applescript 的 NSScrollView 中显示终端输出?
- html - 使用居中文本沿父级拉伸显示 flex 或表格内部 div
- swift - 隐式转换函数接收元组
- python - 如何将 f1 度量添加到 tensorflow 多类 DNN 分类器
- vba - Saving attachments results in memory errors
- java - How to properly manage what has been read from a .txt
- syntax - Lisp:如何使用递归来定义一个给定非负整数 N 的函数,生成从 1 到包括 N 的所有整数的列表?
- c - 如何使用 iplink 用 C 设置 CAN 设备
- ios - 单击tableView中的文本字段时,ScrollView没有向上移动
- django - 在 Django 中创建更新或创建表单视图