Hello
I have a flat file database where all users are stored in .dat files.
each file is structured as follow:
Password
Email
Surname Name
Street Number
Postal area
The name of the .dat file is also the username.
What I'm trying to do is convert all these dat files to mysql. But I'm not really successful! This is what I tried:
<?php
$filename = 'test.dat';
//Open file and read into an array
$lp = @file($filename, 'r');
//Check file
if(! $lp || $lp == null) {
echo 'Cannot find file';
exit();
}
else {
//Loop through all lines
for ($i=0; $i < count($lp); $i++) {
$piece = split("\/", $lp[$i]);
$password = $piece[0];
$email = $piece[1];
$name = $piece[2];
$adres = $piece[3];
$adres2 = $piece[4];
str_replace("dat", "", $filename);
echo "Username: $filename <br>";
echo "Password: $password <br>";
echo "Email: $email <br>";
echo "name: $name <br>";
echo "adres: $adres <br>";
echo "adres2: $adres2 <br>";
echo "<br>";
}
}
?>
But I still have many probs whit this result!
The split function doesn't work! How can I split the lines of the dat file so I can assign them to a variable?
I have more than 600 separated dat files in the dir so should find solution to catch each file. And not define the name at the start of the php file.
All help is very welcome otherwise I will have to do it manually so please HELP.
thx a lot in advance
Ceci