Forum Moderators: coopster
I have received the following error and cant seem to fix it, I think i dont have nay white space near my php tags, none that I am aware of?
Or can this be caused by something else?
Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/CMS/script-files/products/addimgck.php:22) in /home/username/public_html/CMS/script-files/products/addimgck.php on line 158
line 22 = <LINK href="<? echo("$csspath");?>//style.css" type=text/css rel=stylesheet>
line 158 = Header("Content-type: image/gif");
[PHP]
<?php
include("../../config.php");
include("../db-connect.php");
require('../../sas.php');
$description = nl2br($description);
if (is_array($size))
{
$size1 = implode(", " , $size);
}
?>
<HTML>
<HEAD>
<TITLE>Admin Panel</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<LINK href="<? echo("$csspath");?>//style.css" type=text/css rel=stylesheet>
</HEAD>
<BODY>
<br>
<TABLE cellSpacing=5 cellPadding=0 width=760 align=center class="table_white" border=0>
<TBODY>
<TR>
<TD class="BgColor" colspan="2" height="20" align="center"><font class="heading"><b>Content Management System</b></font>
</TD>
</TD></TR>
<TR>
<TD vAlign=top width=21%>
<TABLE cellSpacing=0 cellPadding=10 width=170 border=0>
<TBODY>
<TR>
<TD class=text vAlign=top align=center>
<P><font class="heading2">• Admin Menu •</font></P>
<?php include
("$menupath/menu.php");
?>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</TD>
</TR></TBODY></TABLE></TD>
<TD width="79%" vAlign=top class=border_inside>
<TABLE cellSpacing=0 cellPadding=10 width="89%" border=0>
<TBODY>
<TR>
<TD><BR><BR>
<font class="maintext">
<P>
<br>
<center><font class="maintext">
<?
$add="$UploadDirectory/$userfile_name"; // the dir name & the file name where the file will be stored.
if(move_uploaded_file ($userfile, $add)){
echo "Your product has been added";
chmod("$add",0777);
// inserting it into the Products table
$result=MYSQL_QUERY("INSERT INTO products(
id,
date,
collection,
type,
style,
productCode,
postage,
price,
new,
inStock,
size,
colour,
description,
pic,
thumb
)".
"VALUES ('NULL',
'$date',
'$collection',
'$type',
'$style',
'$productCode',
'$postage',
'$price',
'$new',
'$inStock',
'$size1',
'$colour',
'$description',
'$userfile_name',
'$userfile_name'
)");
echo "<br><br>";
# check for error
if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
}else{echo "Failed to upload file Contact Site admin to fix the problem";
exit;}
///////// Start the thumbnail generation//////////////
$n_width="$thumb_width";
$n_height="$thumb_height";
$tsrc="$ThumbDirectory/$userfile_name"; // Path where thumb nail image will be stored
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$userfile_type=="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////
////////////// starting of JPG thumb nail creation//////////
if($userfile_type=="image/pjpeg"){
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
//////////////// End of JPG thumb nail creation //////////
?>
</center>
<br>
</td>
</TR></TBODY></TABLE>
<?
mysql_close($cid);
?>
[/PHP]
Note: As of PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() [us3.php.net] and ob_end_flush() [us3.php.net] in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.