hi,

I am trying to use stat in a perl script with MySQL.i am getting the following error. do I need to add some kind of a use command at the top?

[EMAIL PROTECTED] cgi-bin]# perl dbtest.pl
Global symbol "$file" requires explicit package name at dbtest.pl line 13.
Global symbol "$size" requires explicit package name at dbtest.pl line 14.
Global symbol "$mtime" requires explicit package name at dbtest.pl line 14.
Global symbol "$file" requires explicit package name at dbtest.pl line 14.
Global symbol "$size" requires explicit package name at dbtest.pl line 16.
Global symbol "$mtime" requires explicit package name at dbtest.pl line 16.
Execution of dbtest.pl aborted due to compilation errors.
[EMAIL PROTECTED] cgi-bin]#

The test script is included at the end.

Regards,

Mel

--------------------------
#!/usr/bin/perl -w
use strict;
use DBI;

my $dbname = "cctvimages"; # define db here --cctvimages
my $host = "localhost";
my $dbuser = 'root';   # define user here --root
my $dbpw = 'melhebron1'; # specify password here --password
my $mscs = "dbi:mysql:dbname=$dbname;host=$host;";
my $dbh = DBI->connect($mscs, $dbuser, $dbpw) or die "Connect fails to
$dbname\nError = ", $DBI::errstr;

$file = "/home/me/images/2003_03_11_14_32_42.jpg";
($size, $mtime) = (stat ($file))[8,9];

my $rows_affected = $dbh->do("INSERT INTO imageinfo
values('null','2003_03_11_14_32_42.jpg', '$size', '$mtime'");

$dbh->commit;
my $sql = "SELECT * FROM imageinfo";
my $sth = $dbh->prepare($sql);
$sth->execute or die"Execute fails: $DBI::errstr\n";
my @results = $sth->fetchrow_array;
foreach(@results) {
        print"$_\n";
}
$sth->finish;
$dbh->disconnect;


_________________________________________________________________
Use MSN Messenger to send music and pics to your friends http://messenger.msn.co.uk




Reply via email to