Page 1 of 1

Problem with script

Posted: Wed Apr 30, 2003 12:39 pm
by Tory
<?
$amount = $_POST['hiddenField'];


for ($i=1; $i<=$amount; $i++) {

$mp3addy[$i] = $_POST['mp3address[$i]'];
$mp3name[$i] = $_POST['mp3name[$i]'];

$fp[$i] = fopen("$mp3addy[$i]", "r");

$fp2[$i] = fopen("./$i - $mp3name[$i].mp3", "w+");


while (!feof ($fp[$i])) {
fwrite($fp2[$i], fgets($fp[$i],4096));
}
fclose($fp[$i]);
fclose($fp2[$i]);

}

?>
Is part of one of my scripts and the part giving me an error.. The error is:
Warning: feof(): supplied argument is not a valid stream resource in <edited out>/htdocs/phptest/test2/mp3trans.php on line 15

Warning: fgets(): supplied argument is not a valid stream resource in <edited out>/htdocs/phptest/test2/mp3trans.php on line 16
Any ideas?

Posted: Wed Apr 30, 2003 1:58 pm
by volka
the files do not exist or your script has not the proper permissions to access them.

Code: Select all

fp[$i] = fopen($mp3addy[$i], "r") or die($mp3addy[$i]. ': cannot open file');

$fp2[$i] = fopen("./$i - $mp3name[$i].mp3", "w+") or die("./$i - $mp3name[$i].mp3 : cannot open file");

Posted: Wed Apr 30, 2003 3:00 pm
by Tory
Ok. I have added that and have found the problem to be that the script is not actually accepting the POST data... I do not know if I have used the [$i] for the correct usage here..

Thanks

Posted: Wed Apr 30, 2003 3:17 pm
by McGruff
print_r($_POST) then you can see all the keys you want to access

I think there might be a problem with your control structure.