Help with php script!
im trying to code a script that will load some url adresses from a file, all these adresses are index's, then open the url and read all the files and print the name, this is embadded in a webpage with content, but all it does is load a blank page with no wrrors…
$file = fopen("/warez/music/links.txt", "r");
while(!feof($file))
{
$url = fgets($file);
$dir = fopen($url);
while (($track = readdir($dir)) !== false)
{
echo "Track: " . $track . "<br />";
}
fclose($dir);
}
fclose($file);
?>```
thaks for any help
keiran420 wrote: im trying to code a script that will load some url adresses from a file, all these adresses are index's, then open the url and read all the files and print the name, this is embadded in a webpage with content, but all it does is load a blank page with no wrrors…
$file = fopen("/warez/music/links.txt", "r");
while(!feof($file))
{
$url = fgets($file);
$dir = fopen($url);
while (($track = readdir($dir)) !== false)
{
echo "Track: " . $track . "<br />";
}
fclose($dir);
}
fclose($file);
?>```
thaks for any help
ok try this.. it might work might not.
<?php
$file = fopen("/warez/music/links.txt", "r");
while(!feof($file))
{
$url = fgets($file);
$dir = fopen($url);
$track = readdir($dir);
while ($track !== false)
{
echo "Track: " . $track . "<br />";
}
fclose($dir);
}
fclose($file);
?>
I think it's because of line 6. With fopen you always need 2 parameter on the line you miss the way you want to open the file …
http://ca3.php.net/manual/en/function.fopen.php
Also when your developping script always set error_reporting at E_ALL so that you see all the error that happen …
Cheers, but it looks like my code is crappyer yet…
i keep getting this now: The connection was reset
and here is the code up to the first 2 lines of one of the directorys im trying to links tracks from
<html>
<head>
<title>Index of /mp3</title>
</head>
<body>
<h1>Index of /mp3</h1>
<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/">Parent Directory</a> -
<img src="/icons/sound2.gif" alt="[SND]"> <a href="764hero_impossible-waste.mp3">764hero_impossible-w..></a> 23-Mar-2004 13:10 3.5M
<img src="/icons/sound2.gif" alt="[SND]"> <a href="764hero_loaded-painted-red.mp3">764hero_loaded-paint..></a> 23-Mar-2004 13:10 5.6M ```
will i have to edit my code to filter all the crap away? i dunno
thanks for the help though :)
adlez wrote: just use this code
<?php
$pages="warez/music/links.txt";
$list = file ($pages);
foreach ($list as $track) {
echo "Track: " .$track ."<br />";
}
?>
Also you can use this which is like…..
<?php
$pages="warez/music/links.txt";
$list = file ($pages);
foreach ($list as $track) {
echo "Track: {.$track} <br />";
}
?>
its easier to understand and include the variable, some like some dont