PDA

View Full Version : خطایابی این قطعه کد PDO



mani_111
دوشنبه 27 اردیبهشت 1395, 18:20 عصر
دوستان ، به نظرتون ایراد این قطعه کد از کجاست ؟

اجرا میشه اما اطلاعات وارد شده به دیتابیس اضافه نمیشه و هیچ اروری هم دریافت نمیکنم !



NEW RECORD

*/
// if the 'id' variable is not set in the URL, we must be creating a new record
else
{
// if the form's submit button is clicked, we need to process the form
if (isset($_POST['submit']))
{
// get the form data
$firstname = htmlentities($_POST['firstname'], ENT_QUOTES);
$lastname = htmlentities($_POST['lastname'], ENT_QUOTES);
$date = $_POST['date'];

// check that firstname and lastname are both not empty
if ($firstname == '' || $lastname == '')
{
// if they are empty, show an error message and display the form
$error = 'ERROR: Please fill in all required fields!';
renderForm($firstname, $lastname, $error);
}
else
{
// insert the new record into the database
if ($stmt = $db->prepare("INSERT players (firstname, lastname, date) VALUES (?, ?, ?)"))
{
$stmt->bind_param("sss", $firstname, $lastname, $date );
$stmt->execute();
$stmt->close();
}
// show an error if the query has an error
else
{
echo "ERROR: Could not prepare SQL statement.";
}

// redirec the user
header("Location: view.php");
}

}
// if the form hasn't been submitted yet, show the form
else
{
renderForm();
}
}

// close the mysqli connection
$db->close();
?>

H:Shojaei
دوشنبه 27 اردیبهشت 1395, 21:18 عصر
اسم فیلد رو date گذاشتید که یه کلمه کلیدیه یا باید داخل ‍‍`` بذاریدش یا تعویضش کنید...