It might have been posted already a few times, but todays is the first day I am here, and tried a few possible solutions already, but nothing would help.
The textfiles looks like:
[Thu Aug 09 07:58:35 2001] [01 Tech] Name (Department) <Rank>
The above is what is put in every line, so that means:
[weekday month day hh:mm:ss year] [number word] word (word) <word>
I started with an example that was posted here earlier, which looks like this (changed it a bit already):
// code to be executed starts here
$file = file("./import.txt");
while (list($key, $val) = each ($file)) {
$val = ereg_replace(" ", ",", $val);
$data = explode(",", $val);
$sql = sprintf("INSERT into test VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
$result = mysql_query($sql, $db);
}
// code to be executed ends here
but that doesn't do anything, no error messages and no insert in my database.
Is there a way I can remove the spaces from my textfile and replace them with \" or anything, so that they will be transfered into seperate textfiles? In fact, all that I want to have put into my database is the NAME itself, the rest can be deleted and must not be entered.
If there is ANYONE in here that might have a solution for me, it would be very much appreciated. Thank you for your efforts!