Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^4: Deleting Old MySql Records With PERL

by Milti (Sexton)
on Jul 13, 2016 at 23:47 UTC ( #1167745=note: print w/replies, xml ) Need Help??

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\ 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1167745]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2019-05-22 07:51 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (138 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!