Page 1 of 1

Quick and Easy question.

Posted: Tue Mar 08, 2011 4:33 pm
by prinbrando
Hi my visitors are tired of having unknown time for their downloads. I think I'm on the right track I'm just having a bit of a problem concatenating I think.

oh ya and it says error on line 7 if that helps
<?php

$filename = 'wisconsin'; //set filename

$hit_count = @file_get_contents('c' .$filename . '.txt'); //concatenate to make "cfilename.txt"
$hit_count++;
(line 7) @file_put_contents(''c' .$filename', $hit_count); // adds 1 count to "cfilename.txt"

header('Content-disposition: attachment; filename="$filename . 'mp3'"'); // tells "filename.mp3"
header('Content-type: audio/mp3');
header('Content-length: '. filesize($filename . '.mp3')); // tells filesize "filename.mp3"
readfile('http://righthere.com/display/sessions/' . $filename . '/' . $filename . '.mp3'); // points to the download file at " 'http://righthere.com/display/sessions/f ... lename.mp3')
?>

Thanks ahead of time. I've just kept on changing it but I still can't get it to run.

Re: Quick and Easy question.

Posted: Tue Mar 08, 2011 4:41 pm
by Peec
(line 7) @file_put_contents(''c' .$filename', $hit_count); // adds 1 count to "cfilename.txt"

You have double single quotes in the start and wrong quote in end of filename.


Should be:

Code: Select all

@file_put_contents('c'.$filename, $hit_count); // adds 1 count to "cfilename.txt"

Re: Quick and Easy question.

Posted: Tue Mar 08, 2011 5:12 pm
by prinbrando
Thank you so much.. now I decided though that I could make it so that I only have to change one variable since I have a few files. That I'm gonna use this code with.
I'm having an error on second to last line a parse error

<?php

$filename = 'wisconsin';
$filecount = 'c' . $filename . '.txt'; // concatenate name cwisconsin.txt
$filedl = $filename . '.mp3'; // concatenate name wisconsin..mp3

$hit_count = @file_get_contents($filecount);
$hit_count++;
@file_put_contents($filecount, $hit_count);

header('Content-disposition: attachment; filename= $filedl');
header('Content-type: audio/mp3');
header('Content-length: '. filesize($filedl'));
(error line) readfile('http://righthere.com/display/sessions/' . $filename . '/' . $filedl); // get file http://righthere.com/display/sessions// ... consin.mp3
?>

Thanks in advance.