Search Webmaster Help and Solution

[RESOLVED] need help with php update code

Noone seems to be able to figure out why this does not update my database records. It says "records updated" but they arent. The 5 records are there, the ids are unique and 2 of them should have been updated. At one time all records were updated but as Ive followed suggestions and changed code its gotten worse. Any help?


PHP Code: <?php
// this code should update the database and gives a confirmation
$ud_id=$_POST[ud_id];
$ud_amtpaid=$_POST[ud_amtpaid];
$ud_rentdue=$_POST[ud_rentdue];
$ud_prevbal=$_POST[ud_prevbal];
$ud_misc=$_POST[ud_misc];
$ud_tentpay=$_POST[ud_tentpay];
$ud_hudpay=$_POST[ud_hudpay];
$ud_datepaid=$_POST[ud_datepaid];
if(($ud_misc + $ud_prevbal + $ud_rentdue) == $ud_amtpaid)
{
$misc = 0;
$prevbal = 0;
$amtpaid = 0;
$tentpay = 0;
$datepaid = ;
}
mysql_connect(localhost,root,);
mysql_select_db(test) or die( Unable to select database);
$query=UPDATE testtable SET amtpaid=.$ud_amtpaid., prevbal=.$ud_prevbal.
, misc=.$ud_misc., tentpay=.$ud_tentpay., hudpay=.$ud_hudpay., datepaid=.$ud_datepaid.  WHERE id=.$ud_id. LIMIT 1;
echo $query. <br>;
mysql_query($query) or die(<b>A fatal MySQL error occured</b>. <br />Query: . $query . <br /> Error: . mysql_error());

echo Records Updated;
mysql_close();
?> Noone seems to be able to figure out why this does not update my database records. It says "records updated" but they arent. The 5 records are there, the ids are unique and 2 of them should have been updated. At one time all records were updated but as Ive followed suggestions and changed code its gotten worse. Any help?


PHP Code: <?php
// this code should update the database and gives a confirmation
$ud_id=$_POST[ud_id];
$ud_amtpaid=$_POST[ud_amtpaid];
$ud_rentdue=$_POST[ud_rentdue];
$ud_prevbal=$_POST[ud_prevbal];
$ud_misc=$_POST[ud_misc];
$ud_tentpay=$_POST[ud_tentpay];
$ud_hudpay=$_POST[ud_hudpay];
$ud_datepaid=$_POST[ud_datepaid];
if(($ud_misc + $ud_prevbal + $ud_rentdue) == $ud_amtpaid)
{
$misc = 0;
$prevbal = 0;
$amtpaid = 0;
$tentpay = 0;
$datepaid = ;
}
mysql_connect(localhost,root,);
mysql_select_db(test) or die( Unable to select database);
$query=UPDATE testtable SET amtpaid=.$ud_amtpaid., prevbal=.$ud_prevbal.
, misc=.$ud_misc., tentpay=.$ud_tentpay., hudpay=.$ud_hudpay., datepaid=.$ud_datepaid.  WHERE id=.$ud_id. LIMIT 1;
echo $query. <br>;
mysql_query($query) or die(<b>A fatal MySQL error occured</b>. <br />Query: . $query . <br /> Error: . mysql_error());

echo Records Updated;
mysql_close();
?>

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).