hello, i think i'm in the right place. having a bit of an issue with my php script passing data.
here is the error message:
"Connected to database
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'item' cannot be null' in /home/ewff/public_html/prac0.php:66 Stack trace: #0 /home/ewff/public_html/prac0.php(66): PDOStatement->execute() #1 {main} thrown in /home/ewff/public_html/prac0.php on line 66"
there are only 4 values to pass. here is the script that is giving me the problem:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$errors = [];
}
if(empty($errors)) {
// prepare sql and bind parameters
$query = "INSERT INTO details (item, temple, quantity, price)
VALUES (:item, :temple, :quantity, :price)";
}
$stmt = $dbh->prepare($query);
$stmt->bindParam(':item', $_POST['item']);
$stmt->bindParam(':temple', $_POST['temple']);
$stmt->bindParam(':quantity', $_POST['quantity']);
$stmt->bindParam(':price', $_POST['price']);
$stmt->execute();
/*** close the database connection ***/
$dbh = null;
?>
if you could please, explain why this is happening so i may learn how to prevent/catch it myself in the future. thank you all much.