RE: [PHP] Update query

From: Date: Thu, 12 Dec 2002 10:48:56 +0000
Subject: RE: [PHP] Update query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127979@lists.php.net to get a copy of this message
It doesn't work in that it doesn't update the database. I have a form which when loaded takes a variable ItemCode from the previous page (which gets the Itemcode from the DB) and puts it into a hidden field which I call oldItemCode, then when I try to update the $ItemCode row in the database with the edited changes using the oldItemCode as an identifier it won't update - It goes to my error message shown below. So what I'm asking is there anything I'm doing wrong. I noted your points about the comma and have changed the code. <? $query = "update products set ItemCode='$ItemCode', ItemName ='$ItemName', catid ='$catid', price = '$price', description = '$description', shortdesc = '$shortdesc', where ItemCode='$oldItemCode'"; $result = mysql_query($query); if (!$result) { echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'>"; echo "<tr><td><img src='images/admin_orders_administrate.gif'></td></tr>"; echo "<tr><td>&nbsp;</td></tr>"; echo "<tr><td><span class='adminisoleipa'>Could not change details: please <a href='mailto:stephen.jackson@violasystems.com'>click here</a> to email the administrator<br><br></span>"; echo "</td>"; echo "</tr>"; echo "</table>"; } else { echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'>"; echo "<tr><td><img src='images/admin_orders_administrate.gif'></td></tr>"; echo "<tr><td>&nbsp;</td></tr>"; echo "<tr><td><span class='adminisoleipa'>Your product has been successfully edited<br><br></span>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "<a href='eshop_uploadproductpicture.php'><img src='images/admin_orders_upload.gif' border='0'></a>"; echo "</td></tr>"; echo "</table>"; } ?>

« previous php.general (#127979) next »