hello,
learning to write a classified script and i'm lost at fixing the following problem.
receiving the following message:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/classified/header.php:24) in /var/www/classified/utility.inc.php on line 35
message appearswhen random_ad_display(function) -> resizeimage(function) is called.
the header.php, is just a title/description of the program and no reference to header found in the header.php script. basic as basic can be.
the following functions are located in utility.inc.php script.
random_ad_display - displays image in a random order in a table.
resizeimage($image1) - resize the image to display in the table.
function random_ad_display($feature_result)
{ echo "<table width='500' align='center' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
$i = 0;
while($row1 = mysql_fetch_array($feature_result))
{ if ($i == 2)
{ echo "</tr>";
echo "<tr>";
$image1 = "images/".$row1["cf_images"];
$test = resizeimage($image1);
// echo "<td width='250' height='120'> <div align='center'> <p align='center'><IMG SRC='images/" . $image1 . "'width='150' height='120' /></p> <p>description and ad number</p></td>";
echo "<td width='250' height='120'> <div align='center'> <p align='center'><IMG SRC='" . $test . "'></p> <p>description </p></td>";
$i = 0;
}
else
{ $image2 = $row1["cf_images"];
echo "<td width='250' height='120'> <div align='center'> <p align='center'><IMG SRC='images/". $image2 . "' width='150' height='120' /> </p> <p> test description 2 testing one two three four five </p></td>"; }
$i++;
}
echo "</tr>";
echo "</table>";
}
/***********************************************************************/
function resizeimage($image1)
{ // The file
$filename = $image1;
// Set a maximum height and width
$width = 140;
$height = 140;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig)
{ $width = $height*$ratio_orig;}
else
{ $height = $width/$ratio_orig; }
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, null, 100);
}
any help you can help me would be greatly appreciated.
thanks