Problem with script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tory
Forum Newbie
Posts: 3
Joined: Wed Apr 30, 2003 12:39 pm

Problem with script

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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");
Tory
Forum Newbie
Posts: 3
Joined: Wed Apr 30, 2003 12:39 pm

Post 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
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Post Reply