in reply to Re^3: Deleting Old MySql Records With PERL
in thread Deleting Old MySql Records With PERL

I'm now using this code. Still getting an error message.

use DBI; use CGI ':standard'; print "Content-type: text/html\n\n"; my $dbh = DBI->connect('dbi:mysql:my_db','searcher','searcherpasswd') or die "Connection Error: $DBI::errstr\n"; $sth = $dbh->prepare ("DELETE FROM my table where DATE <UNIX_TIMESTAMP +(DATE_SUB(NOW()-INTERVAL 30 DAY)"); $sth->execute ();

Error message ---- DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at e:\owner\cgi-bin\search_specialty.pl line 14.

Line 14 is $sth->execute ();

Replies are listed 'Best First'.
Re^5: Deleting Old MySql Records With PERL
by NetWallah (Canon) on Jul 14, 2016 at 05:02 UTC
    See perlfan's reply, below - where he explains that your column name, "date" is a reserved word, and therefore needs to be escaped using backticks.

    For more info, see this stackoverflow article.

            There is no time like the present for postponing what you ought to be doing.