If I have a table with date column formatted 0000-00-00, and I want to force a specified date into the column as opposed to just using "now", how would I change the following? Sorry if this is a little off topic but I thought someone here might know. Not a cross-post, I'm not even on a MySQL list.
Note: The DB apparently opens and executes the command because I don't get the "die" error message, but the data does not show up in the table. It's a 5-column table and I'm inserting into 5 columns, and it works in similar cases, so I assume the problem is the date format? The part I'm asking about specifically is line 16 (defining the date) and line 27 (inserting into the DB). 01 #!/usr/bin/perl -w 02 03 use strict; 04 use CGI; 05 use DBI; 06 $CGI::POST_MAX=1024 * 500; 07 08 my $q = new CGI; 09 my $dbh = DBI->connect("DBI:mysql:db_name:localhost","usr","pass") 10 or die "Could not connect to DB: $!"; 11 my $file = $q->param('uploadfile'); 12 my $month = $q->param('month'); # (01,02,03,04 formatted) # mm 13 my $day = $q->param('day'); # (01,02,03,04 formatted) # dd 14 my $year = $q->param('year'); # (2003,2004 formatted) # yyyy 15 my $storyid = "CMDBNR" . '-' . $year . $month . $day; 16 my $dbdate = $year . '-' . $month . '-' . day; 17 my $line; 18 my $statement; 19 my $sth; 20 open(DBFILE,"<$file") or die "Could not open file to insert into DB: 21 $file: $!\n"; 22 while ($line = <DBFILE>) { 23 chomp($line); 24 # do some regex stuff here to clean up file 25 $/ = "" # slurp whole doc, not line at a time 26 $statement = <<" EOF"; 27 INSERT INTO NewsStories (idate) VALUES ($storyid,$dbdate,NULL,NULL,$line) 28 EOF 29 $sth = $dbh->prepare($statement); 30 $sth->execute; 31 } 32 $sth->finish; 33 $dbh->disconnect; 34 close(DBFILE); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]