Can't include a file twice? [SOLVED]
Posted: Wed Jan 04, 2006 12:14 am
I believe this should work, but for the life of me, I cannot see the problem. When I try to include the same file twice, the parsing stops at the inclusion of the second file. In other words, the contents of the page are normal right up to the end of the first included file and then it's just blank after that -- no more html, not even the closing body and html tags.
Here's the essential code where I wish to include a file twice (actually, I want to include two different files that are nearly clones of one another -- I get the same results trying to include these two files in any combination):
The horizontal rules are there just to help me spot things.
Now here's the code for the included file (and I feel the problem must be in here someplace):
Can anyone please help? Thanks in advance!
Here's the essential code where I wish to include a file twice (actually, I want to include two different files that are nearly clones of one another -- I get the same results trying to include these two files in any combination):
Code: Select all
<hr />
<?php
include ('headline_news.php');
?>
<hr />
<?php
include ('headline_news.php');
?>
<hr />Now here's the code for the included file (and I feel the problem must be in here someplace):
Code: Select all
<?php
$configfile = "news_config.php";
include $configfile;
//=========================================
// FUNCTION: ROW COLOR
//=========================================
function row_color($i, $nrowcolor1, $nrowcolor2) {
$bgcolor1 = $nrowcolor1;
$bgcolor2 = $nrowcolor2;
if ( ($i % 2) == 0 ) {
return $bgcolor1;
} else {
return $bgcolor2;
}
}// END ROW COLOR FUNCTION
echo '<table width="'.$ntable.'" border="'.$nborder.'" cellspacing="'.$ncellspacing.'" cellpadding="'.$ncellpadding.'">'."\n";
$results = @ mysql_query("SELECT * FROM $table WHERE type=1 ORDER BY post_date DESC",$db);
if ($results) {
$i=0;
while ($therow = mysql_fetch_array($results)) {
$color = row_color($i, $nrowcolor1, $nrowcolor2);
$id = $therow["id"];
$post_date = date("m/d", $therow["post_date"]);
$title = stripslashes($therow["title"]);
$shortver = stripslashes($therow["shortver"]);
$longver = stripslashes($therow["longver"]);
echo '
<tr valign="top" bgcolor="'. $color .'">
<td width="1%" class="'.$ndate.'">'.$post_date.'</td>
<td class="'.$nitem.'"><b>'.$title.': </b>'.$shortver;
if (($longver)!="") {
echo ' <a class="'.$nlink.'" href="news-events_single.php?id='.$id.'">'.$nmorelink.'</a>';
}
echo '</td></tr>'."\n";
$i++;
}
} else {
echo '<tr><td class="'.$nnone.'">'.$nnoposts.'</td></tr>';
}
echo "</table>\n";
?>