你好,這裏是我的代碼,我創建了2 SQLite表樣品和login_info正確,雖然這個錯誤仍然彈出問題與PDO結合/執行
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out of range in C:\xampp\htdocs\display.php:22
<?php
session_start();
$user = $_POST['username'] ?? '';
$pword = $_POST['password'] ?? '';
$_SESSION['details'] = [
'user' => $user,
'pword'=> $pword
];
$pdo = new PDO('sqlite:'.__DIR__.'/users.db');
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
if (!isset($_SESSION['sample'])){
$statement = $pdo->prepare("INSERT INTO sample(timecreated) VALUES (?)");
$statement->execute([time()]);
$_SESSION['sample'] = $pdo->lastInsertId();
}
$deleteStatement = $pdo->prepare("DELETE FROM login_info WHERE employee_id=?");
$deleteStatement->execute([$_SESSION['sample']]);
這是我的錯誤開始
$insertStatement = $pdo->prepare("INSERT INTO login_info (username,password) VALUES (?,?)");
$insertStatement->execute([$_SESSION['sample'],'username', $user]);
$insertStatement->execute([$_SESSION['sample'],'password', $pword]);
?>
<!DOCTYPE html>
<html>
<head>
<title>Display</title>
</head>
<body>
<p>
Your username is <?php echo $user ?> and your password <?php echo $pword ?>.
</p>
<a href="login.php">Go Back</a>
</body>
</html>'
是否'$ user'和'$ pword'攜帶價值? –