0
請幫忙,這是正確的事情嗎? 用戶不是在mysql數據庫中創建的。註冊會話執行PDOStatement :: execute():SQLSTATE [HY093]:
<?php
session_start();
if(isset($_SESSION['KlantNr'])){
header("Location: /");
}
require 'database.php';
$message = '';
if(!empty($_POST['EmailAdres'])
&& !empty($_POST['password'])
&& !empty($_POST['KlantVoornaam'])
&& !empty($_POST['KlantAchternaam'])
&& !empty($_POST['Adres'])
&& !empty($_POST['Postcode'])
&& !empty($_POST['Plaats'])
&& !empty($_POST['Geboortedatum'])
&& !empty($_POST['MobielNr'])):
// Enter the new user in the database
$sql = "INSERT INTO Klant ('EmailAdres', 'password', 'KlantVoornaam', 'KlantAchternaam', 'Adres', 'Postcode', 'Plaats', 'MobielNr', 'Geboortedatum')
VALUES (:EmailAdres, :password, :Klantvoornaam, :Klantachternaam, :Adres, :Postcode, :Plaats, :MobielNr, :Geboortedatum)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':EmailAdres', $_POST['EmailAdres']);
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
$stmt->bindParam(':KlantVoornaam', $_POST['KlantVoornaam']);
$stmt->bindParam(':KlantAchternaam', $_POST['KlantAchternaam']);
$stmt->bindParam(':Adres', $_POST['Adres']);
$stmt->bindParam(':Postcode', $_POST['Postcode']);
$stmt->bindParam(':Plaats', $_POST['Plaats']);
$stmt->bindParam(':Geboortedatum', $_POST['Geboortedatum']);
$stmt->bindParam(':MobielNr', $_POST['MobielNr']);
if($stmt->execute()):
$message = 'Created user';
else:
$message = 'Error';
endif;
endif;
?>
警告:PDOStatement對象::執行():SQLSTATE [HY093]:無效參數 編號的:不是在C定義的參數:\ XAMPP \ htdocs中\ register.php上 線38
您在單引號**'包圍你的字段名**和產生的錯誤。如果你想包含它們,你必須使用反引號** **。 – EhsanT