I have a hosting site on a GoDaddy server - using the same php code and same tab-delimited data files. Godaddy no longer supports php4 - and my code no longer works. If some body could take a look and suggest what I might be doing wrong I'd be very appreciative!
The error I'm getting is "Warning: Invalid argument supplied for foreach() in /home/content/n/i/b/nibrs/html/cgi/property.php on line 43"
Code follows:
------
<html>
<body>
<TITLE>
Crime Reporting Unit Property Report
</TITLE>
</HEAD>
<BODY>
<h2>Note: The Following table is a property stolen, with the data converted from NIBRS cases reported by this agency for the year in question. </h2>
<?php
$filename = "/home/content/n/i/b/nibrs/html/datafiles/prop.dat"; //here's the filename
$id = fopen($filename, "r"); //open the file
while ($data = fgetcsv($id, filesize($filename),"\t")) //start a loop
# echo "<br>$data[0]\n";
if ($data[1] == "$ori" and $data[2] == "$year")
$table[] = $data; //put each line into its own entry in the $table array
fclose($id); //close file
echo "<table border='1'>\n";
echo "<tr><td align='center' rowspan='2'>Agency</td><td align='center'rowspan='2'>ORI</td><td align='center'rowspan='2'>Year</td><td align='center'rowspan='2'>Month</td><td align='center'colspan='7'>Robbery by Location</td><td align='center'colspan='2'>Burglary by Location</td><td align='center'colspan='3'>Larceny by Value</td><td align='center'colspan='9'>Nature of Larceny</td><td>Months</td></tr>\n";
echo "<tr><td>Hiway</td><td>Comm. House</td><td>Gas Station</td><td>Conv. Store</td><td>Residence</td><td>Bank</td><td>Misc</td><td>Residence</td><td>Non- Residence</td><td>$200 and Over</td><td>$50 - $200</td><td>Under $50</td>
<td>Pocket- picking</td><td>Purse Snatching</td><td>Shop lifting</td><td>From Motor Veh</td><td>MV Parts/Access</td><td>Bicycle</td><td>From Building</td><td>Coin- op</td><td>All Other</td><td>Reporting</td></tr>\n";
foreach($table as $row)
{
echo "<tr>";
foreach($row as $data)
echo "<td align='center'align='right'>$data</td>";
echo "</tr>\n";
}
echo "</table>\n";
?>
</body>
</html>
Thanks!
Dan B