1
foreach($log_files as $i => $file ) {
ftp_get($conn_id, "tempfile", $file, FTP_ASCII);
$fp = fopen("tempfile","r");
$contents = fread($fp, filesize("tempfile") );
$contents = str_replace(" ","", $contents);
preg_match_all("/TOST Protect: Ident: ([^ ]*) - ([^- ]*) - ([0-9.]*)/", $contents, $matches);
echo "
Log File $i";
foreach($matches[1] as $key => $value) {
$playername = $matches[1][$key];
$playerip = $matches[2][$key];
$playerid = $matches[3][$key];
echo $playername;
echo "
";
echo $playerip;
echo "
";
echo $playerid;
echo "
";
global $xoopsDB;
$sql = "INSERT INTO ".$xoopsDB->prefix('PlayersTOSERV');
$sql .= " ( id, Player, IP, UniqueID ) VALUES ";
$sql .= " ( '', '$playername', '$playerip' , '$playerid')";
echo "SQL insert statement: " . $sql . "
";
$result = $xoopsDB->query($sql) or die('SQL Error: ' . mysql_error());
}
The output in the echo statements work great as it preg_match_all each .log file and outputs an example here.
Log File 1
someplayer
someip
someuniqueid
Log File 2
someplayeragain
anotherip
anotherid
I am getting an error when trying to insert this info into the database. I used echo to see what the statement looked like and it looks good.
SQL insert statement: INSERT INTO __PlayersTOSERV ( id, Player, IP, UniqueID ) VALUES ( '', 'name', 'TACO' , '209.217.83.000')
SQL Error:
The first field is id which is an auto increment in the table so were leaving that blank.
Tablename is good, no spelling or case sensitive typo's. The sql statement show's good values.
I included the mainfile.php
any answers?
Cheers,
Bimmer