Undefined index: HTTP_HOST & Cannot modify header
Posted: Sat Jan 31, 2004 10:57 am
i have been tying for a day or so to fix the following error, i am still a newbie. i am getting the two following errors when i try to load the script.
Notice: Undefined index: HTTP_HOST in C:\Program Files\HTTPd\htdocs\current\html\view_print.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\HTTPd\htdocs\current\html\view_print.php:36) in C:\Program Files\HTTPd\htdocs\current\html\view_print.php on line 36
the script is
<?php
if (is_numeric ($_GET['pid'])) { // Make sure there's a meal ID.
require_once ('../mysql_connect.php'); // Connect to the database.
$query = "SELECT * FROM meal WHERE meal.meal_id = {$_GET['pid']}";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
mysql_close(); // Close the database connection.
// Set the page title and include the HTML header.
$page_title = $row['meal_name'];
//include_once ('includes/header.html');
// Display a header.
echo "<div align=\"center\">
<b>{$row['meal_name']}</b> by
<br />{$row['size']}
<br />\${$row['price']}
<a href=\"add_cart.php?pid={$row['meal_id']}\">Add to Cart</a>
</div><br />";
// Get the image information and display the image.
if ($image = @getimagesize ("../uploads/{$row['image_name']}")) {
echo "<div align=\"center\"><img src=\"../uploads/{$row['image_name']}\" $image[3] alt=\"{$row['print_name']}\" />";
} else {
echo "<div align=\"center\">No image available.";
}
echo '<br />' . stripslashes($row['descripiton']) . '</div>';
include_once ('includes/footer.html'); // Require the HTML footer.
} else { // Redirect
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
exit();
}
?>
ps thank you for replying and answersing my other probelm/posting
Notice: Undefined index: HTTP_HOST in C:\Program Files\HTTPd\htdocs\current\html\view_print.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\HTTPd\htdocs\current\html\view_print.php:36) in C:\Program Files\HTTPd\htdocs\current\html\view_print.php on line 36
the script is
<?php
if (is_numeric ($_GET['pid'])) { // Make sure there's a meal ID.
require_once ('../mysql_connect.php'); // Connect to the database.
$query = "SELECT * FROM meal WHERE meal.meal_id = {$_GET['pid']}";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
mysql_close(); // Close the database connection.
// Set the page title and include the HTML header.
$page_title = $row['meal_name'];
//include_once ('includes/header.html');
// Display a header.
echo "<div align=\"center\">
<b>{$row['meal_name']}</b> by
<br />{$row['size']}
<br />\${$row['price']}
<a href=\"add_cart.php?pid={$row['meal_id']}\">Add to Cart</a>
</div><br />";
// Get the image information and display the image.
if ($image = @getimagesize ("../uploads/{$row['image_name']}")) {
echo "<div align=\"center\"><img src=\"../uploads/{$row['image_name']}\" $image[3] alt=\"{$row['print_name']}\" />";
} else {
echo "<div align=\"center\">No image available.";
}
echo '<br />' . stripslashes($row['descripiton']) . '</div>';
include_once ('includes/footer.html'); // Require the HTML footer.
} else { // Redirect
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
exit();
}
?>
ps thank you for replying and answersing my other probelm/posting