I'm having a problem with MySQL syntax that I cannot resolve. Perhaps you could advise. The purpose of this code is to read an Apache server log file. This section of code is intended to extract the source IP and the taget IP of a communication, the time and date. It is part of a forensic application I'm building. Java/C/Assembly I know, Perl/SQL I'm learning. The syntax I'm using follows and the error msg is after that:
My Code: $insertData = "INSERT INTO url_Connect (sourceIP
dt tm, remoteIP) VALUES ($sourceIP, $date,
$time, $targetIP)";
$dbMake = $dbi->prepare($insertData);
$dbMake->execute(); #<-----line 86
Command line error msg:DBD::mysql::st execute failed: You have an error in your SQL syntax; c
+heck the manual that corresponds to your MySQL server version for the
+ right syntax to use near 'dt, tm, remoteIP) VALUES (192.168.1.1, 23
+/Mar/2008,
04:02:02, 77.91.224.1' at line 2 at createDB.pl li
+ne 86
I have flagged line 86 above, as referred to in the error msg. 192.168.1.1 is a test value I inserted to allow the code succeed without error reporting on that value (please ignore it). What is puzzling me is the large gap in the data above between 23/Mar/2008, and 04:02:02 - the date and time. It appears to be either tabs or spaces, but I have checked the data collected by the regex's and neither tabs nor spaces are present in the data collected. Where does this come from, is this causing my error?
The code I've used to create the table: my $createTable = "CREATE TABLE IF NOT EXISTS
url_Connect(
sourceIP varchar(16) primary k
+ey,
dt date,
tm time,
remoteIP varchar(16)
)";
I've used regex's to extract the data needed to populate these fields, these are working perfectly with no surplus/excess white spaces. The rest of my code opens the logfile, reads every line and extracts the data I require. This executes without error.
Thanks in advance...