Hi all.
I've recently posted a message about this subject, and i see myself before
this situation again because the replys i had in the post gave me clues
but still didn't help!!!
I think the question itself is very simple nervertheless i will pose it
again....
I am in a great trouble inserting a DATETIME value in a mySQL table from a
perl script.
The only way in wich i can insert data is with option number 1. (see below
please)
As you can see option number 1 doesn't help much since i don't know yet
the values i'm going to enter in the database.
Can you please somebody, anybody have a light on this matter.........
The rest of the executes below option number 1 are the result of various
test i've tried each of wich i woul put a "#" on the option that were not
to be tested!
Thanx once again.
G@SP@R Out....
sub insertvaluesdb {
DBI->trace(2,"/tmp/dbi.out");
my $dbh = DBI->connect('DBI:mysql:Facultis') or &error("Couldn't
connect to database: " . DBI->errstr);
my $sth = $dbh->prepare('INSERT INTO salas values (?,?,?,?,?,?,?)') or
&error("Couldn't prepare statement: " . $dbh->errstr);
my $titulo=$FORM{'titulo'};
my $endereco=$FORM{'endereco'};
#Strip http:// from endereco
$endereco=~ s/http:\/\///;
my $descricao=$FORM{'descricao'};
my $area=$FORM{'area'};
my $id=0;
my $time="now()";
my $active="N";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
my $date = sprintf('%04d/%02d/%02d
%02d:%02d:%02d',$year,$month,$mday,$hour,$min,$sec);
ATTENTION
OPTION NUMBER 1
#$sth->execute(0,$titulo,$endereco,$descricao,2001/01/31
21:45:00,$area,N) or &error("Couldn't execute
statement: " . $sth->errstr);
$sth->execute(0,$titulo,$endereco,$descricao,'getdate()',$area,N) or
&error("Couldn't execute statement: " . $sth->errstr);
$sth->execute(0,$titulo,$endereco,$descricao,now(),$area,N) or
&error("Couldn't execute statement: " . $sth->errstr);
$sth->finish;
$dbh->disconnect;
}