Adamhumbug Posted August 18, 2023 Share Posted August 18, 2023 Hi All, I have an insert query where sometimes all of the fields will have values to insert and sometimes they will not. I have allowed null on those fields in the database but i still get a warning (i have them turned on but ideally i would like to remedy the warning rather than turn it off). $stmt->execute([ ':quote_id' => $_GET['quoteid'], ':item_id' => $_POST['itemId'], ':quantity' => $_POST['quantity'], ':start_date' => $_POST['startDate'], ':end_date' => $_POST['endDate'] ]); Start and End date may not have values so i would like to pass in something intentional like 0 or NULL but im not sure how to do that or what doing so is called. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 18, 2023 Share Posted August 18, 2023 ':start_date' => trim($_POST['startDate'])!= '' ? $_POST['startDate'] : null; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.