PHP error when reading for txt file to table
<p>I am getting the following errors</p>

<pre><code>Notice: Undefined variable: header in C:\wamp\www\test\test1.php on line 27
Notice: Undefined variable: row in C:\wamp\www\test\test1.php on line 41
Deprecated: Function split() is deprecated in C:\wamp\www\test\test1.php on line 42
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 43
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 44
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 45
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 46
Notice: Undefined variable: sortkey in C:\wamp\www\test\test1.php on line 47
Deprecated: Function split() is deprecated in C:\wamp\www\test\test1.php on line 42
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 43
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 44
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 45
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 46
Notice: Undefined variable: sortkey in C:\wamp\www\test\test1.php on line 47
Deprecated: Function split() is deprecated in C:\wamp\www\test\test1.php on line 42
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 43
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 44
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 45
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 46
Notice: Undefined variable: sortkey in C:\wamp\www\test\test1.php on line 47
Deprecated: Function split() is deprecated in C:\wamp\www\test\test1.php on line 42
Notice: Undefined offset: 3 in C:\wamp\www\test\test1.php on line 42
Notice: Undefined offset: 2 in C:\wamp\www\test\test1.php on line 42
Notice: Undefined offset: 1 in C:\wamp\www\test\test1.php on line 42
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 43
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 44
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 45
Notice: Undefined variable: sortby in C:\wamp\www\test\test1.php on line 46
Notice: Undefined variable: sortkey in C:\wamp\www\test\test1.php on line 47
</code></pre>

<p>With the following code</p>

<pre><code> &lt;span class="style2"&gt;
&lt;style type="text/css"&gt;
&lt;!--
body, th, td, p, small {
    font-family:'Times New Roman',Times,serif;
    font-size:100%;
    color:#757675;
}
small {font-size:90%;}

td, th {
    background-color:#FFFFFF;
    border:1px solid #CCCCCC;
    padding:7px 20px 7px 20px;
}
th {background-color:#a5a5a5; color:#FFFFFF;}

h1 {font-size:120%; color:#558;}
h1 .sortby {color:#855;}
--&gt;
&lt;/style&gt;
&lt;/span&gt;

&lt;?php
echo '&lt;h1&gt;&lt;span class="sortby"&gt;'.$header.'&lt;/span&gt;&lt;/h1&gt;
&lt;table cellspacing="5" summary="List of demo fields"&gt;
&lt;tr&gt;
&lt;th&gt;Date &amp; Time Added&lt;/th&gt;
&lt;th&gt;Products&lt;/th&gt;
&lt;th&gt;Keys&lt;/th&gt;
&lt;th&gt;Computer&lt;/th&gt;
&lt;/tr&gt;';

$fp = fopen('key.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;'; exit;}

while (!feof($fp)) {
    $line = fgets($fp,1024); //use 2048 if very long lines
    $row++;
    list ($date, $products, $keys, $computer) = split ('\|', $line);
    if ($sortby == 'Date Added') $sortkey = strtolower($date);
    if ($sortby == 'Products') $sortkey = strtolower($products);
    if ($sortby == 'Keys') $sortkey = strtolower($keys);
    if ($sortby == 'Computer') $sortkey = strtolower($computer);
    $col[$row] = array($sortkey, $date, $products, $keys, $computer);
}

fclose($fp);

$arrays = count($col) - 1;

$loop = 0;
while ($loop &lt; $arrays) {
    $loop++;
    echo '
&lt;tr&gt;
&lt;td&gt;'.$col[$loop][1].'&lt;/td&gt;
&lt;td&gt;'.$col[$loop][2].'&lt;/td&gt;
&lt;td&gt;'.$col[$loop][3].'&lt;/td&gt;
&lt;td&gt;'.$col[$loop][4].'&lt;/td&gt;
&lt;/tr&gt;';
}

echo '
&lt;/table&gt;
 '
?&gt;
</code></pre>

<p>BUT my table is showing correctly and is doing what i want it to do I dont know why iam getting these errors. </p>
