I am trying to use $_SESSION to set a variable as a global. I get these two error message: Warning: Cannot send session cookie - headers already sent by (output started at /var/www/html/Pictures/02.php:4) in /var/www/html/Pictures/02.php on line 9
Warning: Cannot send session cache limiter - headers already sent (output started at /var/www/html/Pictures/02.php:4) in /var/www/html/Pictures/02.php on line 9
I am trying to pass the variable $dir_new so that I will be able to read it inside the function. Here is the code.
<html>
<head><title>Process all files</title></head>
<body>
<?php
$exit_test = "$exit";
//echo $exit;
$full_name = "$exit_test";
$dir_new = basename($full_name);
session_register ("dir_new");
print "<h1>$dir_new</h1><br><hr>";
echo $dir_final;
//Open Dir
//$dir = opendir('./') or die($php_errormsg);
$dir = opendir($exit_test) or die($php_errormsg);
while (false !== ($files =readdir($dir))) {
if ('.' == ($files)) {
continue;
}
if ('..' == ($files)) {
continue;
}
if (is_file($files)) {
continue;
}
$file[$x++] = $files;
}
closedir($dir);
foreach($file as $filenum => $filename)
{
//print "$filenum $filename <p>\n";
}
//Create Array 15
$files = array();
//Create Table
function pc_grid_horizontal($array, $size) {
$table_width = 100;
$width = intval($table_width / $size);
$tr = '<tr align="center">';
$td = "<td width=\"$width%%\"><a href=\"pictures/Olympus Camedia/$dir_new/%s\" target=\"window\"><img=\"Replace_Me\"><br>pic</a><br></td>";
//printf ($td,'%s','');
$grid = "<table width=\"$table_width%\" style=\"table_style\">$tr";
$i = 0;
foreach ($array as $e) {
$grid .= sprintf($td, $e);
$i++;
if (!($i % $size)) {
$grid .= "</tr>$tr";
}
}
while ($i % $size) {
$grid .= sprintf($td, ' ');
$i++;
}
$end_tr_len = strlen($tr) * -1;
if (substr($grid, $end_tr_len) != $tr) {
$grid .= '</tr>';
} else {
$grid = substr($grid, 0, $end_tr_len);
}
$grid .= '</table>';
return $grid;
}
$grid = pc_grid_horizontal($file, 5);
print $grid;
?>
Thank you for the help.