Hi all, I hope someone can help me with the following. I have a script that reads a txt file and displays the correct values. I only want to add it to the database now, but I can't manage this. below the script
<?php
include '../includes/connect.php';
if(!$conn)
{
die(mysqli_error());
}
$fd = fopen ("import/8.txt", "r");
while (!feof ($fd))
{
$buffer1 = fgets($fd, 4096);
if (substr($buffer1,0,7)=='#EXTINF')
{
$buffer = fgets($fd, 4096);
$buffer = str_replace("'","`",$buffer);
$array=explode('\\',$buffer);
$count = count($array);
list($artiest,$titel) = explode(' - ',$array[$count-1]);
if (strlen($titel)==0)
{print("$artiest <br>");
list($artiest,$titel) = explode('- ',$array[$count-1]);
if (strlen($titel)==0)
{print("$artiest <br>");
list($artiest,$titel) = explode(' -',$array[$count-1]);
if (strlen($titel)==0)
{
print("$artiest <br>");
list($artiest,$titel) = explode('-',$array[$count-1]);
if (strlen($titel)==0)
{
$buffer = str_replace("'","`",$buffer1);
$pos=strpos($buffer,',');
$tekst = substr($buffer,$pos+1);
list($artiest,$titel) = explode(' - ',$tekst);
if (strlen($titel)==0)
{
list($artiest,$titel) = explode('- ',$tekst);
if (strlen($titel)==0)
{
list($artiest,$titel) = explode(' -',$tekst);
if (strlen($titel)==0)
{
list($artiest,$titel) = explode('-',$tekst);
if (strlen($titel)==0)
print("$artiest <br>");
$sql= "INSERT INTO mp3 (id_dj,artiest,titel) VALUES ('8','$artiest','$titel')";
}
}
}
}
}
}
}
}
}
echo "import mp3's klaar";
?>