Re: Include file error, common one I think
| From: | Jo�o C�ndido de Souza Neto | Date: | Sat, 13 Jan 2007 18:30:44 +0000 |
| Subject: | Re: Include file error, common one I think | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247038@lists.php.net to get a copy of this message | ||
Is it the whole code of your file, or is there any other html code?
"Chris Carter" <chandan9sharma@yahoo.com> escreveu na mensagem
news:8316202.post@talk.nabble.com...
>
> Hi,
>
> Here is code that I got from the internet for random image. This file
> works
> perfect if I try it independently but not on any existing file. I think
> the
> error that I am getting is quite common on the net but its new for me.
>
> I am getting this error:
>
> Warning: Cannot modify header information - headers already sent by
> (output
> started at /folder/test.php:12) in /folder/randomimage.php on line 19
>
> the code that I got from net:
>
> <?
> $folder = 'images/';
> $exts = 'jpg jpeg png gif';
> $files = array(); $i = -1;
> if ('' == $folder) $folder = './';
> $handle = opendir($folder);
> $exts = explode(' ', $exts);
> while (false !== ($file = readdir($handle))) {
> foreach($exts as $ext) {
> if (preg_match('/\.'.$ext.'$/i', $file, $test)) {
> $files[] = $file;
> ++$i;
> }
> }
> }
> closedir($handle);
> mt_srand((double)microtime()*1000000);
> $rand = mt_rand(0, $i);
>
>
> Line 19 is below:
>
> header('Location: '.$folder.$files[$rand]);
> ?>
>
> Thanks a bunch.
> Chris
> --
> View this message in context:
>
> http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8316202
> Sent from the PHP - General mailing list archive at Nabble.com.