Include file error, common one I think
| From: | Chris Carter | Date: | Sat, 13 Jan 2007 17:44:53 +0000 |
| Subject: | Include file error, common one I think | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-247034@lists.php.net to get a copy of this message | ||
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.