PHP problems

software development

#1

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??

  1. 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


#2

Hello -

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

[quote]Warning: Cannot add header information - headers already sent
by (output started at

[/quote]

…usually means that there is a carriage return or something before the 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

#3

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 "
    "; while ($row = mysql_fetch_row($result)) { $Cat=$row[0]; $CatID=$row[1]; fontFace("Arial","
  • $Cat
  • "); } echo "
"; 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

<? 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 “

    ”;
    while ($row = mysql_fetch_row($result)) {
    $Cat=$row[0];
    $CatID=$row[1];
    fontFace(“Arial”,”
  • $Cat
  • ");
    }
    echo “
”;

commonFooter($Relative,$UID);
?>

Welcome

Welcome to The Virtual Kitchen, your best source to see the programming capabiltities of CobyInteractive. Use the demo site to:

  • Shop for Items
  • Pay for Items in Real Time Using Credit Cards
  • Update your store
  • Upload images to your store
  • Manage the content of the whole site
  • Add a banner ad rotation system

(Ad Copy) 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.


© 2003
CobyInteractive

150 Fifth Avenue

New York, NY 14623

Phone: 1-718-832-1304

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