[SOLVED] MySQL UPDATE woes
Posted: Sat Aug 13, 2005 3:37 am
Hi All,
I'm banging my head on this one. Can any one point out my errors?
I'm not getting any errors in the apache logs etc.
The database will just not update
I'm banging my head on this one. Can any one point out my errors?
I'm not getting any errors in the apache logs etc.
The database will just not update
Code: Select all
<?php
include "../includes/functions.inc";
// Open connection to the database
mysql_connect("localhost", "materials", "materials")
or die("Failure to communicate with database");
mysql_select_db("materialsregister");
$action = isset($_GET['action']) ? $_GET['action'] : '';
if (isset($_GET['action']) ? $_GET['action'] : '') {
// Format the data
$summaryId = $_POST['summaryId'];
$paperCategoryId = $_POST['paperCategoryId'];
$colloPaperName = $_POST['colloPaperName'];
$manufacturerName = $_POST['manufacturerName'];
$cpl = $_POST['cpl'];
// Update values
$query = "UPDATE ausapapersummary SET paperCategoryId='$paperCategoryId', colloPaperName='$colloPaperName', manufacturerName='$manufacturerName', cpl='$cpl' WHERE summaryId = 122";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
$success_msg = "<P>Your comment has been updated.</P>";
}
else {
error_log(mysql_error());
$success_msg = "<P>Something went wrong.</P>";
}
}
else {
// Get the comment header and comment
$summaryId = isset($_GET['summaryId']) ? $_GET['summaryId'] : '';
$sql_query = mysql_query("SELECT * FROM ausapapersummary WHERE summaryId = 122");
$query_data = mysql_fetch_array($sql_query);
$colloPaperName = $query_data['colloPaperName'];
$manufacturerName = $query_data['manufacturerName'];
$cpl = $query_data['cpl'];
print "<html><title></title><head></head><body>";
echo "<form name=\"editSASummary\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"updateSummary\">";
echo "<input type=\"hidden\" name=\"summaryId\" value=$summaryId>";
echo "<table class=\"sorttable\">\n";
$second = array('Collo Paper Name','Manufactured Name','Computer Loopup Prefix');
$secondTitles = array('colloPaperName','manufacturerName','cpl');
$secondValues = array($colloPaperName,$manufacturerName,$cpl);
for($x = 0; $x<count($second); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$second[$x]."</td>\n";
echo "<td width=\"200px\" colspan=\"4\"><input type=\"text\" name=\"".$secondTitles[$x]."\" size=\"50\" maxlength=\"100\" value=\"".$secondValues[$x]."\"></td></tr>\n\n";
}
echo "<INPUT TYPE=\"hidden\" NAME=\"summaryId\" VALUE=$summaryId>";
echo "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit\"></body></html>";
}
?>