Hey I'm using DBI to put a date entered value into a mysql database. However I'm having problems. My date column in NOTNULL but when i enter the date (as a string) from my perl script, whilst all other columns are filled, the date entered column remains 0000-00-00. I know it is calculating the date corectly, the prob seems to be entering the date into the database
Any ideas? Here's my code
Thanks a lot
Jim
Any ideas? Here's my code
Code:
my ($day,$mon,$year) = (localtime)[3..5];
my $dateImported=(printf "%d-%02d-%02d\n",$year+1900,$mon+1,$day); #COOL CODE, BUT NOT WORKING (SHOULD RETURN INTEGER NOT STRING? NOT SURE WHY THIS IS)
#print $dateImported;
#open(OUT, '>output.txt') or die "couldnt open";
#$dump = Dumper($query);
#print Dumper($query);
#all important mySQL to put into the database what is needed
my $sql1 = "INSERT INTO user_BP_Files (fileName,userName,bioPaxfile,dateImported) VALUES (?,?,?,?)";
#now prepare and execute
my $sth1 = $dbh->prepare( $sql1 );
$sth1->bind_param(1, $fileName);
$sth1->bind_param(2, "userName");
$sth1->bind_param(3, $BPfile);
$sth1->bind_param(4, $dateImported); #NOT WORKING? NOT SURE WHY
Thanks a lot
Jim