PHP problems

PHP problems

Posted by: cobyco
Posted on: 2003-04-11 16:46:00

Can anyone help me with two problems I'm having.

I've built a shopping cart (www.warrenzanes.com/Cart/index.php) using MyCart and it seems to work fine but for a couple of things
1) often when I access the homepage of a shopping cart I'm working on I get the error message -

Warning: Cannot add header information - headers already sent by (output started at /home/.penguinoven/warren/warrenzanes.com/Cart/index.php:11) in /home/.penguinoven/warren/warrenzanes.com/Cart/index.php on line 49
Select a category:

But when I access the homepage from inside the shopping cart I do not get the error

I have no idea why this is happening, possibly I have not setup the file structure correctly??

2) the second error message I get is when I'm trying to up upload an image from the admin folder (www.warrenzanes.com/Cart/admin/index.php) The error message is -

Warning: exec() has been disabled for security reasons in /home/.penguinoven/warren/warrenzanes.com/Cart/admin/uploadItem.php on line 4

Warning: Cannot add header information - headers already sent by (output started at /home/.penguinoven/warren/warrenzanes.com/Cart/admin/uploadItem.php:4) in /home/.penguinoven/warren/warrenzanes.com/Cart/admin/uploadItem.php on line 5


any suggestions would be appreciated

Thanx
Cobyco
administrator
www.warrenzanes.com



Re: PHP problems

Posted by: Jeff @ DreamHost
Posted on: 2003-04-11 16:51:00

Hello -

I don't know about your specific problem, but in PHP the following error:

> Warning: Cannot add header information - headers already sent
> by (output started at

...usually means that there is a carriage return or something before the <php or php> portions at the top and bottom of included files. This usually only becomes a problem if you are trying to output headers on your own somewhere within the script, in which case the added content messes with the parsing.

I don't know to what extent you were involved in writing/editing the script, but you should check and see if there are any strange newlines anywhere (and check the specific line referenced in the error and see what shows up there)...

Hope this helps!

- Jeff @ DreamHost
- DH Discussion Forum Admin

Re: PHP problems

Posted by: cobyco
Posted on: 2003-04-11 17:18:00

This is the original code that works fine
<?
require("Cart.php");
DBinfo();
Brand();
Root();
mysql_connect("$DBHost","$DBUser","$DBPass");
$old=date("z")-1;
mysql("$DBName","DELETE FROM Users WHERE Date < $old");

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
while ($row=mysql_fetch_row($result)) {
$CII=$row[0];
$CDa=$row[1];
$pieces=explode(":",$CDa);
$DCHK=$pieces[1];
if ($DCHK < $old) {
mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");
}
}


if ($UID != "") {
$result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");
$num=mysql_num_rows($result);
if ($num == "0") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
}

if ($UID == "") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
commonHeader("$Company","Select a category");

$result=mysql("$DBName","SELECT * FROM Category ORDER BY Category");
fontFace("Arial","Select a category:

");
echo "<ul>";
while ($row = mysql_fetch_row($result)) {
$Cat=$row[0];
$CatID=$row[1];
fontFace("Arial","<li><a href='$Relative/items.php?CA=$CatID&UID=$UID'>$Cat</a></li>");
}
echo "</ul>";

commonFooter($Relative,$UID);
?>

The error at line 49 is:
Header("Location: $PHP_SELF?UID=$UID");

But the page looked plain of course so I added a table and some graphics (I want to use this to try and get some work)

so the whole code is this: sorry about the length

<table width="705" border="0">
<tr>
<td colspan="3"><div align="center"><img src="images/banner_new.gif" width="705" height="90"></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="233"><?
require("Cart.php");
DBinfo();
Brand();
Root();
mysql_connect("$DBHost","$DBUser","$DBPass");
$old=date("z")-1;
mysql("$DBName","DELETE FROM Users WHERE Date < $old");

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
while ($row=mysql_fetch_row($result)) {
$CII=$row[0];
$CDa=$row[1];
$pieces=explode(":",$CDa);
$DCHK=$pieces[1];
if ($DCHK < $old) {
mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");
}
}


if ($UID != "") {
$result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");
$num=mysql_num_rows($result);
if ($num == "0") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
}

if ($UID == "") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
commonHeader("$Company","Select a category");

$result=mysql("$DBName","SELECT * FROM Category ORDER BY Category");
fontFace("Arial","Select a category:

");
echo "<ul>";
while ($row = mysql_fetch_row($result)) {
$Cat=$row[0];
$CatID=$row[1];
fontFace("Arial","<li><a href='$Relative/items.php?CA=$CatID&UID=$UID'>$Cat</a></li>");
}
echo "</ul>";

commonFooter($Relative,$UID);
?>
</td>
<td width="24"> </td>
<td width="440"><h1 align="center"><font face="Arial, Helvetica, sans-serif">Welcome</font></h1>
<p><font face="Arial, Helvetica, sans-serif">Welcome to The Virtual Kitchen,
your best source to see the programming capabiltities of CobyInteractive.
Use the demo site to:</font></p>
<ul>
<li><font face="Arial, Helvetica, sans-serif">Shop for Items</font></li>
<li><font face="Arial, Helvetica, sans-serif">Pay for Items in Real Time
Using Credit Cards</font></li>
<li><font face="Arial, Helvetica, sans-serif">Update your store</font></li>
<li><font face="Arial, Helvetica, sans-serif">Upload images to your store</font></li>
<li><font face="Arial, Helvetica, sans-serif">Manage the content of the
whole site</font></li>
<li><font face="Arial, Helvetica, sans-serif">Add a banner ad rotation
system</font></li>
</ul>
<p> </p>
<p><font color="#FF0000" face="Arial, Helvetica, sans-serif">(Ad Copy)</font><font face="Arial, Helvetica, sans-serif"> Here
you can browse our catalog for all your ingredient needs: rices, spices,
dried fruits, and more. We carry only the best cooking utensils as
well. From knives and forks to pots and pans, you'll never have to
frown if you cook with our hardware. Why go anywhere else? We have
all you need to make that special, gourmet meal.</font></p></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"><hr width="600" noshade></td>
</tr>
<tr>
<td colspan="3"><div align="right"><font size="1" face="Arial, Helvetica, sans-serif"><small>

<img src="images/vklogosm.jpg" width="73" height="79" align="right">© 2003
CobyInteractive

150 Fifth Avenue

New York, NY 14623

Phone: 1-718-832-1304</small></font></div></td>
</tr>
</table>

I checking the release notes, I think I have not set the
Header("Location: $PHP_SELF?UID=$UID");
corectly
Could I send you the release notes in word and you could possibly take a look?

thanx for all you help

Tags: shopping cartphpadmin indexerror messageheadershomepageaccessaddfile structurethanxexecappreciatedupload