Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Deleting Old MySql Records With PERL

by Milti (Beadle)
on Jul 13, 2016 at 23:47 UTC ( [id://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\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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-09-08 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.