Text file to database
Posted: Sun Feb 02, 2003 10:33 am
HI
I`m trying to read data from a text file and then store it into the database so i can save the content of the text file daily, A kind of backup:
to read the file i`m using
$filename = "backup.txt";
$fp = fopen ($filename, "r" ) or die ("could not find file");
while ( ! feof( $fp ) ){
$line = fgets ($fp, 1024 );
print "$line<BR>";
}
this prints out the file but how do i convert this into a single string like
$data= nl2br($line);
so i can add it to the database
Thanks
I`m trying to read data from a text file and then store it into the database so i can save the content of the text file daily, A kind of backup:
to read the file i`m using
$filename = "backup.txt";
$fp = fopen ($filename, "r" ) or die ("could not find file");
while ( ! feof( $fp ) ){
$line = fgets ($fp, 1024 );
print "$line<BR>";
}
this prints out the file but how do i convert this into a single string like
$data= nl2br($line);
so i can add it to the database
Thanks