In the first case you initialize $content to blank, but in the second case you do not:
PHP Code:
else if($id==""||main_page=='index.php')
{
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">';
Add
$content = "";
to get this:
PHP Code:
else if($id==""||main_page=='index.php')
{
$content = "";
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">';
A more elegant method would be to initialize it at the top of the file:
PHP Code:
$id=$_GET['products_id'];
$content = "";
if($id!="")
Looks like DrByte beat me to it with the critical bit:)