0을 반환하는 lastInsertID에 문제가 있습니다. 다른 페이지에서 작업 중이므로 여기에 잘못된 것이 있습니다.PDO lastInsertID가 0을 반환합니다.
다음은 try/catch 블록에 있습니다.
$idCount = "42";
/** set the database **/
$db = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
/** set the error reporting attribute **/
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT image1 FROM items WHERE `id` = :id");
/** bind the parameters **/
$stmt->bindParam(':id', $idCount, PDO::PARAM_STR);
$stmt->execute();
$idCount = $db->lastInsertId();
echo $idCount;
유 항목에서 –