Following an OS update, a PHP script that has run well for years has suddenly developed a truncating errors that I can't figure out. It was written by someone who's no longer available, so I don't know any more than I can see.
The script processes a text file to extract titles then build a numbered list with links to create new pages to display the related short articles and a photo.
The text file contains entries such as:
#22:New Channel
AD:One mile north of Old Harbor
DT:1905-06
PN:NewCut1905.jpg
PT:Hydraulic Dredge Works on New Harbor Channel
TX:Because the Kalamazoo River did not have enough water discharge to scour a clear channel through the tremen....
In the html list, the above entry was appearing as a link reading "22.New Channel" but now displays as "2.N"
The entire script is further below, but where it seems to be failing is on:
$entar[$entCt] = $ar[1];
$entTlar[$entCt] = $ar[2];
The entire name, such as "New Channel" is in $ar[2] but $entTlar[$entCt] ends up with nothing more than the first letter. The accompanying numbers are also being truncated to the first numeral so that 21,21,23 become 2,2,2
Here's the entire script as it is now. I intend to clean up the html but the PHP is more critical.
<?php
$file = ''; $tfile = ''; $ln = ''; $entCt = 0; $perCol = 0; $i = 0; $j = 0;
$entar = ''; $entTlar = ''; $s = '';
$file = fopen("entry.txt", 'r');
while(!feof($file)) {
$ln = fgets($file, 1024);
if(substr($ln, 0, 1) == '#') { // entry number line
preg_match('/^.(\d+):(.*)$/', $ln, $ar); // separate entry # & short title
if(substr($ar[2], 0, 4) == ' ---') continue; // skip unused numbers
$entar[$entCt] = $ar[1];
$entTlar[$entCt] = $ar[2];
++$entCt;
}
}
fclose($file);
$perCol = floor(($entCt + 3) / 4); // show entries in 4 columns
//echo "perCol= $perCol<br>";
//$c1 = $c2 = $c3= $c4='';
for($i = 0; $i < $perCol; ++$i) { // 1/4rd of the entries in each column
$in = $entar[$i]; $it = $entTlar[$i];
$s .= "<tr><td width=25%><a href=\"entry.php?$in\"><b>$in</b>. $it</a></td>"; // column 1
//$c1.="$i,$in;";
$in = $entar[$i+$perCol]; $it = $entTlar[$i+$perCol];
$s .= "<td width=25%><a href=\"entry.php?$in\"><b>$in</b>. $it</a></td>"; // column 2
//$c2.="$i,$in;";
$j = $i + ($perCol * 2);
if($j >= $entCt) { $s .= "</tr>\n"; continue; }
$in = $entar[$j]; $it = $entTlar[$j];
$s .= "<td width=25%><a href=\"entry.php?$in\"><b>$in</b>. $it</a></td>"; // column 3
//$c3.="$i,$in;";
$j = $i + ($perCol * 3);
if($j >= $entCt) { $s .= "</tr>\n"; continue; }
$in = $entar[$j]; $it = $entTlar[$j];
$s .= "<td width=25%><a href=\"entry.php?$in\"><b>$in</b>. $it</a></td></tr>\n"; // column 4
//$c4.="$i,$in;";
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Explore the Map</title>
</head>
<body bgcolor="c0c0d0" marginwidth=20 link="000055" vlink="222266">
<center>
<H1>• Welcome to the Tales of the Villages Album •</H1><H2>Click Here For Tales and Photographs
<a href="mapCt.php">.</a></H2>
<?php
echo "<table width=95% border=1>";
echo "$s";
echo "</table>";
?>
</center>
</body>
</html>
$entar = '';is this variable a string or array?$entar = [];and it would fix it. No telling what other issues might arise though. This older code could definitely use a refresh.