I am recieving a notice(s) multiple times when running a file:
Notice: Undefined index: Telephone in C:\xampp\htdocs\demo\nest_Demo_thrasher.php on line 111
Notice: Undefined index: eMail in C:\xampp\htdocs\demo\nest_Demo_thrasher.php on line 112
I have researched this and the ways to solve it. Most ways involve isset it seems, but none of my code in this example use Get.
Note: This code comes from a class I am taking on-line. I did not write the code. I have noticed during the class that the instructor has presented us files to download that contain obvious errors. When he runs this particular file he gets no notices like I am getting.
I also suspect that this has something directly to do with the DB - When I examine the structure of a particular table, it does not contain Telephone or Email rows to save data in, but all of the other necessary rows are there. Again, he created the DB/tables, not me. Is it possible that he forgot these rows and that is why I am getting these notices?
If the code runs and tries to store/retrieve data from rows that do not exist, that would be a major over-site, correct?
Here is his code:
`
<?php
/*
* File: nest_Demo_thrasher.php
* By: TMIT
* Date: 2010-06-01
*
* This script demonstrates in-elegant database thrashing
* with a nested processing loop
*
*
*=========================================================================
*/
{ // Secure Connection Script
if ($dbSuccess) {
{ // Style declarations
echo '<h1>All Persons by Company</h1>';
// Company SQL
$tCompany_SQLselect = "SELECT tCompany.ID AS companyID, ";
$tCompany_SQLselect .= "tCompany.preName, tCompany.Name, tCompany.RegType ";
$tCompany_SQLselect .= "FROM tCompany ";
$tCompany_SQLselect .= "ORDER BY tCompany.Name, tCompany.preName, tCompany.ID ";
$tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect);
{ // while more company records
while ($rowCompany = mysql_fetch_array($tCompany_SQLselect_Query, MYSQL_ASSOC)) {
$CompanyID = $rowCompany['companyID'];
$CompanypreName = $rowCompany['preName'];
$CompanyName = $rowCompany['Name'];
$CompanyRegType = $rowCompany['RegType'];
$CompanyFullName = trim($CompanypreName." ".$CompanyName." ".$CompanyRegType);
echo '<h2 '.$indent50.'>'.$CompanyFullName.'</h2>';
echo '<div '.$indent100.'>';
echo "<table border='1'>";
echo "<tr>";
echo "<td>#</td>";
echo "<td>Salutation</td>";
echo "<td>FirstName</td>";
echo "<td>LastName</td>";
echo "<td>Telephone</td>";
echo "<td>eMail</td>";
echo "</tr>";
{ // Person Table for companyID
{// Person SQL
$tPerson_SQLselect = "SELECT ";
$tPerson_SQLselect .= "tPerson.ID AS personID, ";
$tPerson_SQLselect .= "tPerson.Salutation, ";
$tPerson_SQLselect .= "tPerson.FirstName, tPerson.LastName ";
$tPerson_SQLselect .= "FROM tPerson ";
$tPerson_SQLselect .= "WHERE tPerson.CompanyID = ".$CompanyID." ";
$tPerson_SQLselect .= "ORDER BY tPerson.LastName, tPerson.FirstName ";
$tPerson_SQLselect_Query = mysql_query($tPerson_SQLselect);
// end person SQL
}
$currentCompanyID = -1;
$indx = 0;
echo '<div '.$textFont.'>';
{ // while more person records
while ($row = mysql_fetch_array($tPerson_SQLselect_Query, MYSQL_ASSOC)) {
$personID = $row['personID'];
$Salutation = $row['Salutation'];
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$Telephone = $row['Telephone'];
$eMail = $row['eMail'];
{ // Create and format a row for each person
if (($indx % 2) == 1) {$rowClass = $trOdd; } else { $rowClass = $trEven; }
echo '<tr '.$rowClass.'>';
echo "<td>".$personID." </td>"; // this is NOT tPerson.ID
echo "<td>".$Salutation." </td>";
echo "<td>".$FirstName." </td>";
echo "<td>".$LastName." </td>";
echo "<td>".$Telephone." </td>";
echo "<td>".$eMail." </td>";
echo "</tr>";
// END: Create and format a row for each person
}
$indx++;
}
// END: // while more person records
}
// END: Person Table for companyID
}
echo "</table>";
echo '</div>';
}
// END: while more company records
}
echo '</div>';
mysql_free_result($tPerson_SQLselect_Query);
}
?>
`