SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My date of birth does not insert in the database. Please help.

    here's the table

    Code MySQL:
    CREATE TABLE IF NOT EXISTS `cf360_wanted_persons_problems` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT,
      `uid` text NOT NULL,
      `rank` varchar(100) NOT NULL,
      `name` varchar(100) NOT NULL,
      `fstname` varchar(100) NOT NULL,
      `alias` varchar(100) CHARACTER SET latin1 NOT NULL,
      `idno` varchar(100) NOT NULL,
      `case_no` varchar(100) CHARACTER SET latin1 NOT NULL,
      `aquisition_request` varchar(100) CHARACTER SET latin1 NOT NULL,
      `persal_no` varchar(255) CHARACTER SET latin1 NOT NULL,
      `division` varchar(255) CHARACTER SET latin1 NOT NULL,
      `stationname` varchar(100) NOT NULL,
      `stationadd` text NOT NULL,
      `physicaladd` text NOT NULL,
      `postalcode` varchar(50) NOT NULL,
      `telecntct` varchar(100) NOT NULL,
      `fax` varchar(100) NOT NULL,
      `stationemail` varchar(100) NOT NULL,
      `emailaddress` varchar(100) NOT NULL,
      `afsbjct` varchar(100) NOT NULL,
      `ocomments` text NOT NULL,
      `datecaptured` datetime NOT NULL,
      `officialdate` datetime NOT NULL,
      `uemail` text NOT NULL,
      `ulocation` text NOT NULL,
      `uphone` text NOT NULL,
      `rep` bigint(20) NOT NULL,
      `status` bigint(20) NOT NULL,
      `time_spent` bigint(20) NOT NULL,
      `category` bigint(20) NOT NULL,
      `close_date` datetime NOT NULL,
      `department` bigint(20) NOT NULL,
      `rdescription` bigint(20) NOT NULL,
      `offender_description` bigint(20) NOT NULL,
      `declaration_description` bigint(20) NOT NULL,
      `countries` bigint(20) NOT NULL,
      `provinces` bigint(20) NOT NULL,
      `title` text NOT NULL,
      `description` text NOT NULL,
      `crime_description` text CHARACTER SET latin1 NOT NULL,
      `scars_remarks_description` text CHARACTER SET latin1 NOT NULL,
      `remarks_description` text CHARACTER SET latin1 NOT NULL,
      `caution_description` text CHARACTER SET latin1 NOT NULL,
      `statement_remarks_description` text CHARACTER SET latin1 NOT NULL,
      `reward` text CHARACTER SET latin1 NOT NULL,
      `place_of_birth` varchar(100) CHARACTER SET latin1 NOT NULL,
      `last_known_location` varchar(100) CHARACTER SET latin1 NOT NULL,
      `race` varchar(100) CHARACTER SET latin1 NOT NULL,
      `sex` varchar(100) CHARACTER SET latin1 NOT NULL,
      `eyes` varchar(100) CHARACTER SET latin1 NOT NULL,
      `hair` varchar(100) CHARACTER SET latin1 NOT NULL,
      `weight` bigint(20) NOT NULL,
      `height` bigint(20) NOT NULL,
      `build` varchar(100) CHARACTER SET latin1 NOT NULL,
      `solution` text NOT NULL,
      `start_date` datetime NOT NULL,
      `date_of_birth` date NOT NULL,
      `crime_date` varchar(100) CHARACTER SET latin1 NOT NULL,
      `age` smallint(20) NOT NULL,
      `priority` bigint(20) NOT NULL,
      `entered_by` bigint(20) NOT NULL,
      `kb` bigint(20) NOT NULL,
      UNIQUE KEY `id` (`id`),
      KEY `rep` (`rep`,`status`,`category`,`department`,`priority`),
      FULLTEXT KEY `solution` (`solution`),
      FULLTEXT KEY `description` (`description`),
      FULLTEXT KEY `title` (`title`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;



    Here's the code to insert to db


    PHP Code:
    <?php
    defined
    ('_JEXEC') or die('Restricted access');
    //check user auth level
    require_once JPATH_COMPONENT.DS.'helpers'.DS.'head.php';
    require_once 
    JPATH_COMPONENT.DS.'helpers'.DS.'auth.php';
    $mainframe = &JFactory::getApplication();    
    if(!
    checkusermin('user') && !config('allowanonymous')) $mainframe->redirect('index.php'JText::_('ALERTNOTAUTH'));

    /*
    NOTE: If we make any changes to this class, we need to make similar changes to helpers/imap.php
    because the class is duplicated there.
    */

    class TableDetail extends JTable
    {
        var 
    $id null;
        var 
    $uid null;
        var 
    $uemail null;
        var 
    $ulocation null;
        var 
    $uphone null;
        var 
    $rep null;
        
    /*########################*/
        
    var $name null;
        var 
    $fstname null;
            var 
    $case_no null;
        var 
    $alias null;
            var 
    $idno null;
        var 
    $rank null;
        var 
    $fax null;
            
    //var $countries = null;
        
    var $stationemail null;
        var 
    $stationname null;
        var 
    $stationadd null;
        var 
    $physicaladd null;
        var 
    $postalcode null;
        var 
    $telecntct null;
        var 
    $emailaddress null;
        var 
    $afsbjct null;
        var 
    $ocomments null;
        var 
    $datecaptured null;
        var 
    $officialdate null;
        
    /*########################*/
        
    var $status null;
        var 
    $time_spent null;
        var 
    $category null;
        var 
    $close_date null;
        var 
    $department null;
        var 
    $countries null;
            var 
    $date_of_birth null;
            var 
    $missing_date null;
            var 
    $success_date null;
            var 
    $place_of_birth null;
            var 
    $last_known_location null;
            var 
    $race null;
            var 
    $sex null;
            var 
    $eyes null;
            var 
    $hair null;
            var 
    $weight null;
            var 
    $height null;
            var 
    $build null;
        var 
    $title null;
        var 
    $description null;
            var 
    $crime_description null;
            var 
    $scars_remarks_description null;
            var 
    $remarks_description null;
            var 
    $caution_description null;
            var 
    $statement_remarks_description null;
            var 
    $reward null;
        var 
    $solution null;
        var 
    $start_date null;
        var 
    $priority null;
        var 
    $entered_by null;
        var 
    $kb null;
        
        function 
    __construct(&$db)
        {
            
    parent::__construct('#__wanted_persons_problems','id',$db);
        }
    }


    Here's my drop down function


    function date_dropdown($year_limit = 0)
    {

            $html_output = '    
    <div id="date_select" >'."\n";

            $html_output .= '        
    <label for="date_day"></label>'."\n";

     

            /*days*/

            $html_output .= '           
    <select name="date_day" id="day_select">'."\n";

                for ($day = 1; $day <= 31; $day++) {

                    $html_output .= '               
    <option>' . $day . '</option>'."\n";

                }

            $html_output .= '           
    </select>'."\n";

     

            /*months*/

            $html_output .= '           
    <select name="date_month" id="month_select" >'."\n";

            $months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

                for ($month = 1; $month <= 12; $month++) {

                    $html_output .= '               
    <option value="' . $month . '">' . $months[$month] . '</option>'."\n";
                    
                }

            $html_output .= '           
    </select>'."\n";

     

            /*years*/

            $html_output .= '           
    <select name="date_year" id="year_select">'."\n";

                for ($year = 1900; $year <= (date("Y") - $year_limit); $year++) {

                    $html_output .= '               
    <option>' . $year . '</option>'."\n";

                }

            $html_output .= '           
    </select>'."\n";

     

            $html_output .= '   
    </div>'."\n";
            
            $date_of_birth = $day ."-". $month ."-". $year;

        return $html_output;

    }

    And here's my html



    HTML Code:
    <tr>
                                <td class="easdwnunder" style="width: 40%;">DATE OF BIRTH:</td>
                                <td class="dwnunder2" style="width: 40%;"><div style="width: 100%;">
                                  <?php 
                                                        if($newproblem && !$printing)
                                                        {
                                                            ?>
                                        <!--<select style="visibility:hidden;" name="date_of_birth" id="date_of_birthid" tabindex="4">
                                        </select>-->
                                        <?php echo date_dropdown($this->row->date_of_birth); ?>
                                   <?php 
                                                        }
                                                        else
                                                        { 
                                                           echo safe_out($this->row->date_of_birth);
                                                        //echo date_dropdown();
                                                        }
                                                    ?>
                                            
                                </div></td>
                                
                              </tr>
    Last edited by cpradio; Oct 28, 2013 at 05:40. Reason: Added formatting tags

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    $date_of_birth = $day ."-". $month ."-". $year;
    MySQL date format is Y-m-d (specificalyl YYYY-MM-DD). I'm guessing you've malformed your input. (The database is probably balking at you trying to tell it the Day is 1975)
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •