Valid query statement not updating db
Posted: Mon Feb 09, 2004 8:44 am
This code:
is not updating the record. Here's the generated Query Statement:
I've tried it with single quotes arounf the Amt and Qty values as well, even though it should not need them, and it is no help. I need another set of eyes -- what am I missing?

Code: Select all
<?php
include "db_connect.php";
if (isset($_POST['Recno'])) // user has approved data input
{
$Query = "UPDATE Exprec SET Desc='" . addslashes($_POST['Desc']) . "'";
if (isset($_POST['Qty']))
$Query .= ",Qty=" . $_POST['Qty'];
if (isset($_POST['Amt']))
{ $Pamt = 0.00 + $_POST['Amt'];
$Query .= ",Amt=$Pamt";
}
$Query .= " WHERE id=" . $_POST['Recno'];
mysql_query($Query, $Link);
echo "<script>onload=function(){opener.location.reload(true);self.close()}</script>";
exit;
}
?>Desc is a varchar column, Qty & id are ints, and Amt a decimal. The include file connects to the db and I know it works. The isset(...)) loop is executing, becuuse the window-closing script at the bottom of it is executing. The record number (id) is correct.UPDATE Exprec SET Desc='reports generated',Qty=14,Amt=8.5 WHERE id=2
I've tried it with single quotes arounf the Amt and Qty values as well, even though it should not need them, and it is no help. I need another set of eyes -- what am I missing?