I need to write a perl script that can do updates on a mysql table, but I haven't really done a lot with perl yet, especially not database stuff. I got this code somewhere on this forum, but can't get it to work. I still want to do major changes, but I need at least to connect to the database. I get an Internal Server Error, in other words there's a syntax error somewhere. (Btw, does anyone know how to see on which line number an error has occured in your perl script, instead of showing "Internal server error"?)
Code: Select all
#!/opt/perl/bin/perl
use DBI;
$dsn = "DBI:mysql:database=mydatabase";
$dbh=DBI->connect($dsn, "myusername", "mypassword");
$sth = $dbh->prepare("SELECT * FROM Leave where Leave_ID=''5''");
$sth->execute;
while( (@results = $sth->fetchrow) != NULL) {
print "$resultsї'Leave_FromDate']\n";
}In the end my objective is to call this perl script from the cron program every first day of each month and add 2 extra leave days for each employee...
Thanks