I have the following script:
function draw_det_content($id)
{
db_connect();
$id=de_code_url($id);
$html="";
$main=str_replace("'","''",$main);
$sub=str_replace("'","''",$sub);
$r=mysql_query("SELECT * FROM products WHERE product_id ='$id'");
if(mysql_affected_rows())
{
$row=mysql_fetch_array($r);
$name=$row["name"];
$price=$row["price"];
$brand=$row["brand"];
$image=$row["image"];
$description=$row["description"];
$pid=$row["product_id"];
$link=$row["url"];
if(strcmp("",$image))
$html.=""; //content here;
db_close();
print $html;
}
else
header( “Location: 404.shtml” );
}
When the product is not available the 404.shtml page should show.
But I get the following error message:
Warning: Cannot modify header information - headers already sent by (output started at /home/densclot/public_html/jackets/index.php:171) in /home/densclot/public_html/jackets/functions.php on line 1167
The relevant section in the index.php file is:
if(isset($p))
{
db_connect();
$r=mysql_query(“SELECT * FROM products WHERE product_id=’”.de_code_url($p)."’");
$row=mysql_fetch_array($r);
$page_title=$row["name"];
$msg=substr($row["description"],0,150);
$meta_desc="$msg..";
$meta_keywords="$page_title,";
$link=code_url($row["product_id"]);
$canonical="$base_url/p/$link/";
db_close();
}
I need help to modify the script to return the 404 header.
Thank you.