Beste allen, ik heb een stukje script dat een txt bestand uitleest en alles plaatst zoals ik het wil hebben. Hij doet dat prima enkel wil ik nu dat hij die ook in de database plaatst. Ik heb verschillende pogingen gedaan maar zonder resultaat. Graag hoop ik op jullie advies hieronder de code:
<?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";
?>
Alvast erg bedankt
<?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";
?>
Alvast erg bedankt