Reputation: 2093
Basically I'm having a go at using PHP to create a basic CMS for my website. I'm trying to write a script which creates a SPRY navigation bar from a CSV file, but the server stops rendering when it reaches the include() function which calls the script. I've checked the Apache error logs and there's nothing in there, also at the beginning of the script I echo'd a HTML comment, but that doesn't appear in the page source, so it would seem it doesn't even start to run? Any ideas as to what it could be?
Template Header File (Included with PHP in main page file, works fine):
<div id="header">
<div style="float:left; height:inherit;"><a href="/"> <img src="/uploads/logo.png height="150px" alt="Bradfield & Bentley" /> </a> </div>
<div style="float: right;"></div>
<div id="navigation" style="clear:both;">
<p></p>
<ul id="MenuBar1" class="MenuBarHorizontal">
<?php include($_SERVER['DOCUMENT_ROOT'].'/templatefiles/navigation.php'); ?>
</ul>
</div>
</div>
<div id="contain">
<div id="spacer">
<p></p>
</div>
The 'navigation.php' file (The one that the server stops rendering when included):
<?php
echo "<!-- File Opened -->";
$row = 1;
if (($handle = fopen($_SERVER['DOCUMENT_ROOT'].'/templatefiles/navigation.csv', "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
echo "<li><a href=\"".$data[$2]."\">".$data[$1]."<a/><li><BR/>";
}
fclose($handle);
}
?>
Upvotes: 0
Views: 2302
Reputation: 4141
try it with
error_reporting(E_ALL);
ini_set('display_errors',1);
the alternative to "having a error in your script" may be, that you have an endless loop and reach the memory_lmit and the thread is killed.
Upvotes: 2
Reputation: 883
When a page stops rendering, this means a fatal php error. Include, however, doesn't throw a fatal error, just a warning. You probably have some error in that php file.
Upvotes: 0
Reputation: 46900
Because this file has a syntax error
echo "<li><a href=\"".$data[$2]."\">".$data[$1]."<a/><li><BR/>";
You cannot have numeric variable names. It should be $data[2]
if you wish to access that index of $data
array.
Upvotes: 0