I have a perl script to update my SQL 2003 database with a bit of information, including a user inputed date. The problem is that the wrong date is being put into the database. Everytime I check it says the date is "1900/01/01 0:00:00" Even though I put "10/24/06" into the date field. Here is the script code:
#!/user/bin/perl -w use CGI q~:standard~; use CGI::Carp qw(fatalsToBrowser); use strict; use DBI; print "content-type: text/html\n\n"; my ($dbh, $sth, $sitepath, @file, $Update, $Name, $Region, $Region_sec +tion, $POS, $NPC, $Requierments, $Requiredquests, $Fame, $Reward, $Rewardtype, $Title, $isrepeatable, $walkthough, $Results, $date); $sitepath = 'e:/web/public_html/finalfantasyinfo'; $Update = param('Update'); $Name = param('Name'); $Region = param('Region'); $Region_section = param('Region_Section'); $POS = param('POS'); $NPC = param('NPC'); $Requierments = param('Requierments'); $Requiredquests = param('Requiredquests'); $Fame = param('Fame'); $Reward = param('Reward'); $Rewardtype = param('Rewardtype'); $Title = param('Title'); $isrepeatable = param('isrepeatable'); $walkthough = param('walkthough'); $date = param('date'); $dbh = DBI -> connect ('dbi:ODBC:', '', '') or die "$DBI::errstr;"; if ($Update eq 'on') { if ($Region != 'No Update') { $sth = $dbh -> prepare (qq~update quests set region = '$Region +' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Region_section != 'No Update') { $sth = $dbh -> prepare (qq~update quests set region_region = ' +$Region_section' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($POS != 'No Update') { $sth = $dbh -> prepare (qq~update quests set pos = '$POS' wher +e quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($NPC != 'No Update') { $sth = $dbh -> prepare (qq~update quests set npc = '$NPC' wher +e quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Requierments != 'No Update') { $sth = $dbh -> prepare (qq~update quests set requierments = '$ +Requierments' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Requiredquests != 'No Update') { $sth = $dbh -> prepare (qq~update quests set requiredquests = +'$Requiredquests' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Fame != 'No Update') { $sth = $dbh -> prepare (qq~update quests set fame = '$Fame' wh +ere quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Reward != 'No Update') { $sth = $dbh -> prepare (qq~update quests set reward = '$Reward +' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Rewardtype != 'No Update') { $sth = $dbh -> prepare (qq~update quests set rewardtype = '$Re +wardtype' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($Title != 'No Update') { $sth = $dbh -> prepare (qq~update quests set title = '$Title' +where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($isrepeatable != 'No Update') { $sth = $dbh -> prepare (qq~update quests set isrepeatable = '$ +isrepeatable' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($walkthough != 'No Update') { $sth = $dbh -> prepare (qq~update quests set walkthough = '$wa +lkthough' where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } if ($date != 'No Update') { $sth = $dbh -> prepare (qq~update quests set updated = '$date' + where quest_name = '$Name'~) or die "$DBI::errstr"; $sth -> execute or die "$DBI::errstr"; } } else { $sth = $dbh -> prepare (qq~insert into quests (quest_name, region, + region_section, pos, npc, requierments, requiredquests, fame, reward +, rewardtype, title, isrepeatable, walkthough, updated) values ('$Nam +e', '$Region', '$Region_section', '$POS', '$NPC', '$Requierments', '$ +Requiredquests', '$Fame', '$Reward', '$Rewardtype', '$Title', '$isrep +eatable', '$walkthough', '$date')~); $sth -> execute or die "$DBI::errstr;"; } $dbh -> disconnect();

In reply to Can not insert Date by Eagle_f90

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.