Trouble saving datetime picker value into database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gggram2000
    New Member
    • Nov 2007
    • 97

    Trouble saving datetime picker value into database

    Hi, I'm using php 5.2.3 with mysql server 5.1 as backend.
    I have a program in which a person enters or chooses two dates from two datetime pickers and other info, I'm not sure if the problem is in the Datatype for the datetime picker declared in the table editor why none of the fields save in the database. I entered the datatype as DATE. and my datetime pickers code look like this:
    Code:
    <script language="javascript" type="text/javascript" src="datetimepicker.js">
    
    //Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
    //Script featured on JavaScript Kit (http://www.javascriptkit.com)
    //For this script, visit http://www.javascriptkit.com 
    
    </script>
    
    //DATES-called from scripts
    //Function CreateInputField($field_title,$input_type,$input_name,$input_value,$input_size,$td_width)                                    
    $f1->createInputField("<b>$lang->reservDate:</b>",'text','reserv_date',"$redate_value",'40','150');
    $f1->createInputField("<b>$lang->departDate:</b>",'text','reserv_date2',"$redate2_value",'40','150');
    
    echo "Select Arrival Date: <a href=\"javascript:NewCal('reserv_date','ddmmyyyy')\"><img src=\"../images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>                             ";
    echo "            Select Departure Date: <a href=\"javascript:NewCal('reserv_date2','ddmmyyyy')\"><img src=\"../images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
    Any help will be greatly appreciated...t hanks mites
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Originally posted by gggram2000
    Hi, I'm using php 5.2.3 with mysql server 5.1 as backend.
    I have a program in which a person enters or chooses two dates from two datetime pickers and other info, I'm not sure if the problem is in the Datatype for the datetime picker declared in the table editor why none of the fields save in the database. I entered the datatype as DATE. and my datetime pickers code look like this:
    Code:
    <script language="javascript" type="text/javascript" src="datetimepicker.js">
    
    //Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
    //Script featured on JavaScript Kit (http://www.javascriptkit.com)
    //For this script, visit http://www.javascriptkit.com 
    
    </script>
    
    //DATES-called from scripts
    //Function CreateInputField($field_title,$input_type,$input_name,$input_value,$input_size,$td_width)                                    
    $f1->createInputField("<b>$lang->reservDate:</b>",'text','reserv_date',"$redate_value",'40','150');
    $f1->createInputField("<b>$lang->departDate:</b>",'text','reserv_date2',"$redate2_value",'40','150');
    
    echo "Select Arrival Date: <a href=\"javascript:NewCal('reserv_date','ddmmyyyy')\"><img src=\"../images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>                             ";
    echo "            Select Departure Date: <a href=\"javascript:NewCal('reserv_date2','ddmmyyyy')\"><img src=\"../images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
    Any help will be greatly appreciated...t hanks mites
    What says TengYong Ng to the fact that his code doesn't run for you? You should write your own code (read posting guidelines).

    Anyway,you copied the wrong code. This code runs on the client browser, but it does not run on the server. You have not even a single PHP command in "your" code and not even a single SQL-command to save the entered value into the database.

    Comment

    • gggram2000
      New Member
      • Nov 2007
      • 97

      #3
      Originally posted by chaarmann
      What says TengYong Ng to the fact that his code doesn't run for you? You should write your own code (read posting guidelines).

      Anyway,you copied the wrong code. This code runs on the client browser, but it does not run on the server. You have not even a single PHP command in "your" code and not even a single SQL-command to save the entered value into the database.
      Yeah thanks, Basically I would like to know whether DATE is a proper Datatype for a datetimepicker?

      ---GM

      Comment

      • chaarmann
        Recognized Expert Contributor
        • Nov 2007
        • 785

        #4
        Originally posted by gggram2000
        Yeah thanks, Basically I would like to know whether DATE is a proper Datatype for a datetimepicker?

        ---GM
        That's the type of question with which you make friends here.

        You should use TIMESTAMP or DATETIME for storing the date and time. DATE only can store the date, but not the time. This is different from oracle-db where DATE also can store the time.
        Use TIMESTAMP if you need high resolution up to the milliseconds and if all dates are after 1970. Else use DATETIME

        Comment

        • gggram2000
          New Member
          • Nov 2007
          • 97

          #5
          Originally posted by chaarmann
          That's the type of question with which you make friends here.

          You should use TIMESTAMP or DATETIME for storing the date and time. DATE only can store the date, but not the time. This is different from oracle-db where DATE also can store the time.
          Use TIMESTAMP if you need high resolution up to the milliseconds and if all dates are after 1970. Else use DATETIME
          Thanks chaarmann...I appreciate ur help

          Comment

          Working...