我试图通过另一个php文件获取我已经插入到数据库中的最后一个id,而在当前的php文件中,我无法获取使用它的最后一个id。
这是我的密码。
<?php
include "connection.php.php";
$sucess = 105;
$fail = 107;
$planImage = $_POST['projects_plan_images'];
$planFilename = $_POST['projectsPlanImagesNames'];
$last_id = mysqli_insert_id($con);
$planLength = count($planFilename);
for($i = 0; $i < $planLength; $i++) {
$imageNow = time();
$new_imageFilename = $imageNow . "_" . $planFilename[$i];
$sql6 = "INSERT INTO projects_plans_images(project_id, plan_image, plan_name) VALUES ('$last_id','$new_imageFilename','$new_imageFilename')";
$result6 = mysqli_query($con, $sql6);
$binary=base64_decode($planImage[$i]);
$file = fopen('files/plans_images/' . $new_imageFilename, 'wb');
fwrite($file, $binary);
fclose($file);
}
$jsonResult = '{"state":';
if($result){
$jsonResult.= $sucess;
}else {
$jsonResult.= $fail;
}
$jsonResult .="}";
print_r($jsonResult);
?>
暂无答案!
目前还没有任何答案,快来回答吧!