close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

insert NULL or empty string to datetime column

Thread began 1/26/2016 4:40 pm by Jason | Last modified 1/29/2016 1:27 am by Ray Borduin | 326 views | 6 replies |

Jason

insert NULL or empty string to datetime column

I'm trying to get my insert to insert NULL or and empty string when the $_POST["checkin_open_date"]." ".$_POST["checkin_open_time"] or $_POST["checkin_close_date"]." ".$_POST["checkin_close_time"] is left blank on the form. I've tried WA_BLANK and WA_NULL, but niether of them seem to be working. Any idea what I'm doing wrong here? I'm attaching a screenshot of the table structure so you can see that the default value for the columns is set to default to NULL. I've also tried WA_DEFAULT, but no luck there either. The only thing I can think of is it's the concatenating, but I didn't know if that would matter.


php:
<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  
$InsertQuery = new WA_MySQLi_Query($local_i);
  
$InsertQuery->Action "insert";
  
$InsertQuery->Table "schedule_event_checkin";
  
$InsertQuery->bindColumn("schedule_id""i""".((isset($_GET["schedule_id"]))?$_GET["schedule_id"]:"")  ."""WA_DEFAULT");
  
$InsertQuery->bindColumn("checkin_open_date""t""".((isset($_POST["checkin_open_date"])." ".isset($_POST["checkin_open_time"]))?$_POST["checkin_open_date"]." ".$_POST["checkin_open_time"]:"")  ."""WA_DEFAULT");
  
$InsertQuery->bindColumn("checkin_close_date""t""".((($_POST["checkin_close_date"])." ".($_POST["checkin_close_time"]))?$_POST["checkin_close_date"]." ".$_POST["checkin_close_time"]:"")  ."""WA_DEFAULT");
  
$InsertQuery->saveInSession("");
  
$InsertQuery->execute();
  
$InsertGoTo "";
  if (
function_exists("rel2abs")) $InsertGoTo $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
  
$InsertQuery->redirect($InsertGoTo);
}
?>
Sign in to reply to this post

Ray BorduinWebAssist

What is the value in the database after the insert? If you give me ftp access and a url to test I can debug it for you.

Sign in to reply to this post

Jason

It's been inserting the current date and time, 1970, or all zero's depending on what I've tried. The current code inserts the current date and time.

UPDATE:
Sorry it just occurred to me that you may need some additional info. To duplicate the issue.

Type an event name, pick a start date, and check the "All Day" checkbox.

Scroll down and check the "Online Checkin" checkbox

Click Submit.

This should trigger the insert on line 196 to insert a record with NULL values for the checkin_open_date and checkin_close_date columns. The issue is that it inserts a value instead of NULL even when you leave the date and time fields on the form blank.

See private message for credentials

Sign in to reply to this post

Ray BorduinWebAssist

I see the problem.... the issue is that even if you leave both blank you are inserting the space between the date and time.

You have bound the value to:

php:
<?php echo((isset($_POST["slide_start_date"])." ".($_POST["slide_start_time"]))?$_POST["slide_start_date"]." ".$_POST["slide_start_time"]:""); ?>



Instead try using:

php:
<?php echo((isset($_POST["slide_start_date"])?$_POST["slide_start_date"]:"") . (isset($_POST["slide_start_time"])?" ".$_POST["slide_start_time"]:"")); ?>
Sign in to reply to this post

Jason

No luck. That inserts the current date.

Sign in to reply to this post

Ray BorduinWebAssist

OK I think I see my mistake... the values will still be set when they are blank. So let's check to see if the value is blank instead like:

php:
<?php echo($_POST["slide_start_date"] . (($_POST["slide_start_time"] != "")?" ".$_POST["slide_start_time"]:"")); ?>
Sign in to reply to this post

Jason

DING DING DING, WINNER WINNER CHICKEN DINNER! Thanks so much for the excellent support as usual Ray, and also for explaining the logic behind the changes. It's much appreciated. Now get some rest, it's after work hours buddy.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...