hightechredneck
01-05-2007, 08:46 PM
This script displays data from the table and immediately below the display are inputs to update 2 fields in the row.
A couple of things are going on, this is strange! First, the data isn't being updated, and then I get the following:
With error reporting set to: error_reporting (E_ALL) I had a notice saying id was not defined. I defined id: $id =""; at the top of the script and the part of the script that displays the current info in the row disappears, leaving only the inputs to update the info. Then when I echo:
$result = mysql_query ($query) or die (mysql_error());
It doesn't print any errors.
Here's the bulk of the script:
<?php # PHP Script - submit debtors resolution.php
// This displays debtors info.
$query = "SELECT * FROM debtors WHERE id = '$id' LIMIT 1";
$result = mysql_query ($query);
if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {// Display each record.
echo '<table border="2" width="95%" cellspacing="3" cellpadding="3" align="center">';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Business Name:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2" color="#FF0000"><b>' . $row[2] . '</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Responsible Party:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2" color="#FF0000"><b>' . $row[3] . '</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Address:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[7] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>City:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[4] . '</font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>State:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[5] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>Zip Code:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[6] . '</font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Amount Owed:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[8] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>Date of Default:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[10] . '</font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Resolved?</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[11] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>Date Resolved:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[12] . '</font>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
}
if (isset($_POST['Submit'])) { // Handle the form.
$query = "SELECT * FROM debtors WHERE id = '$id' LIMIT 1";
$result = mysql_query ($query) or die (mysql_error());
// Validate the purchase date, web site, pixels.
// Check for resolved status
if (!empty($_POST['resolved'])){
$r = escape_data($_POST['resolved']);
} else {
$r = FALSE;
echo '<p><font color="red">Please update resolved status!</font></p>';
}
// Check for date resolved
if (!empty($_POST['date_resolved'])){
$dr = escape_data($_POST['date_resolved']);
} else {
$dr = FALSE;
echo '<p><font color="red">Please enter the date this debt was resolved!</font></p>';
}
if ('$r' && '$dr') {
$query = "UPDATE debtors SET resolved ='$r', date_resolved = '$dr' WHERE id = '$id' LIMIT 1";
$result = mysql_query ($query) or die (mysql_error()); // Run the query.
if ($result) { // If it ran OK.
echo '<h3>Your debtor resolution has been posted.</h3>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
exit();
} else { // If it did not run OK.
// Send a message to the error log, if desired.
echo '<p><font color="red" size="+1">Your debtor information could not be updated due to a system error.</font></p>';
}
}
mysql_close(); // Close the database connection.
} // End of the main Submit conditional.
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="524288">
<fieldset><legend><font size="3" color="#0000CC" face="Arial, Helvetica, sans-serif"><b>Update
your debtor's info here:</b></font></legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="5"> </td>
<td colspan="2" rowspan="2"> </td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="2" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><b>Is
this debt resolved?</b></font></td>
<td width="12%" valign="top"> </td>
<td colspan="2" valign="top">
<input type="text" name="resolved" maxlength="3">
</td>
<td colspan="2" valign="top" rowspan="3"> </td>
</tr>
<tr>
<td colspan="2" valign="top"> </td>
<td width="12%" valign="top"> </td>
<td colspan="2" valign="top"> </td>
</tr>
<tr>
<td colspan="2" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><b>Date
the debt was resolved:<br>
</b><font color="#FF0000">(mm/dd/yyyy)</font></font></td>
<td width="12%" valign="top"> </td>
<td colspan="2" valign="top">
<input type="text" name="date_resolved" maxlength="10" size="10">
</td>
</tr>
<tr>
<td valign="top" colspan="2"> </td>
</tr>
<tr align="center">
<td colspan="7"><font face="Arial, Helvetica, sans-serif" size="2"><b><i>Click"Submit",
to update!<br>
</i></b></font></td>
</tr>
<tr>
<td align="center" colspan="7"> <font face="Arial, Helvetica, sans-serif">
<input type="submit" name="Submit" value="Submit" />
</font></td>
</tr>
</table>
</fieldset>
</form><!-- End of Form -->
</td>
<td width="15%"> </td>
</tr>
</table>
What could be causing this?
Thanks
T
A couple of things are going on, this is strange! First, the data isn't being updated, and then I get the following:
With error reporting set to: error_reporting (E_ALL) I had a notice saying id was not defined. I defined id: $id =""; at the top of the script and the part of the script that displays the current info in the row disappears, leaving only the inputs to update the info. Then when I echo:
$result = mysql_query ($query) or die (mysql_error());
It doesn't print any errors.
Here's the bulk of the script:
<?php # PHP Script - submit debtors resolution.php
// This displays debtors info.
$query = "SELECT * FROM debtors WHERE id = '$id' LIMIT 1";
$result = mysql_query ($query);
if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {// Display each record.
echo '<table border="2" width="95%" cellspacing="3" cellpadding="3" align="center">';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Business Name:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2" color="#FF0000"><b>' . $row[2] . '</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Responsible Party:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2" color="#FF0000"><b>' . $row[3] . '</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"> </font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Address:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[7] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>City:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[4] . '</font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>State:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[5] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>Zip Code:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[6] . '</font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Amount Owed:</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[8] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>Date of Default:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[10] . '</font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2"><b>Resolved?</b></font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<p><font face="arial" size="2">' . $row[11] . '</font></p>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2"><b>Date Resolved:</b></font>';
echo '</td>';
echo '<td valign="top" align="left">';
echo '<font face="arial" size="2">' . $row[12] . '</font>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
}
if (isset($_POST['Submit'])) { // Handle the form.
$query = "SELECT * FROM debtors WHERE id = '$id' LIMIT 1";
$result = mysql_query ($query) or die (mysql_error());
// Validate the purchase date, web site, pixels.
// Check for resolved status
if (!empty($_POST['resolved'])){
$r = escape_data($_POST['resolved']);
} else {
$r = FALSE;
echo '<p><font color="red">Please update resolved status!</font></p>';
}
// Check for date resolved
if (!empty($_POST['date_resolved'])){
$dr = escape_data($_POST['date_resolved']);
} else {
$dr = FALSE;
echo '<p><font color="red">Please enter the date this debt was resolved!</font></p>';
}
if ('$r' && '$dr') {
$query = "UPDATE debtors SET resolved ='$r', date_resolved = '$dr' WHERE id = '$id' LIMIT 1";
$result = mysql_query ($query) or die (mysql_error()); // Run the query.
if ($result) { // If it ran OK.
echo '<h3>Your debtor resolution has been posted.</h3>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
exit();
} else { // If it did not run OK.
// Send a message to the error log, if desired.
echo '<p><font color="red" size="+1">Your debtor information could not be updated due to a system error.</font></p>';
}
}
mysql_close(); // Close the database connection.
} // End of the main Submit conditional.
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="524288">
<fieldset><legend><font size="3" color="#0000CC" face="Arial, Helvetica, sans-serif"><b>Update
your debtor's info here:</b></font></legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="5"> </td>
<td colspan="2" rowspan="2"> </td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="2" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><b>Is
this debt resolved?</b></font></td>
<td width="12%" valign="top"> </td>
<td colspan="2" valign="top">
<input type="text" name="resolved" maxlength="3">
</td>
<td colspan="2" valign="top" rowspan="3"> </td>
</tr>
<tr>
<td colspan="2" valign="top"> </td>
<td width="12%" valign="top"> </td>
<td colspan="2" valign="top"> </td>
</tr>
<tr>
<td colspan="2" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><b>Date
the debt was resolved:<br>
</b><font color="#FF0000">(mm/dd/yyyy)</font></font></td>
<td width="12%" valign="top"> </td>
<td colspan="2" valign="top">
<input type="text" name="date_resolved" maxlength="10" size="10">
</td>
</tr>
<tr>
<td valign="top" colspan="2"> </td>
</tr>
<tr align="center">
<td colspan="7"><font face="Arial, Helvetica, sans-serif" size="2"><b><i>Click"Submit",
to update!<br>
</i></b></font></td>
</tr>
<tr>
<td align="center" colspan="7"> <font face="Arial, Helvetica, sans-serif">
<input type="submit" name="Submit" value="Submit" />
</font></td>
</tr>
</table>
</fieldset>
</form><!-- End of Form -->
</td>
<td width="15%"> </td>
</tr>
</table>
What could be causing this?
Thanks
T