I'm trying to write a script that will read from a text list of songs
that I burned onto my CD (Albums011.txt), then write to the database
text the new text made ready for inserting into a database.
The entries from the Albums011.txt look like this:
Wayne Newton - Wild Cool & Swingin' - 03 - But Not For Me.mp3
Wayne Newton - Wild Cool & Swingin' - 04 - Wives And Lovers.mp3 etc.
and I want to manipulate it them to look in the database.txt like this:
INSERT INTO `lists` VALUES ( "Albums012", "Wayne Newton - Wild Cool &
Swingin' - 03 - But Not For Me.mp3 3.25MB 192k ");
INSERT INTO `lists` VALUES ( "Albums012", "Wayne Newton - Wild Cool &
Swingin' - 04 - Wives And Lovers.mp3 2.88MB 192k ");
but I can't seem to get the proper syntax to get the result I want. Can
anyone help? Thanks.
The non-working code I've written is below:
<?php
$filename = 'e:\mirc\CDLists\Albums011.txt';
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);
$filename = 'e:\mirc\CDLists\database.txt';
$fp = fopen($filename, "a");
$string = $contents;
foreach($string as $key=>$val){
$write = fputs($fp, "INSERT INTO `lists` VALUES (
\"Albums011\",\"$val\"); \n");
}
fclose($fp);
?>