I have an update statement that is not working according to plan.
It is updating some of the fields but not the others.
This is my code. I partially build the string by determining which fields need to be populated. After the database update, I email the query to myself to see what exactly executed and it looks fine.
but when check the record contents some arent marked.
$todaysdate=date("Y-m-d");
$query_update="update IRSRequest set ";
if($UAT_date == "") { $query_update = $query_update."UAT_date='$todaysdate', "; }
if($Required_Date == "") { $query_update = $query_update."required_date='$todaysdate', "; }
if($del_date == "") { $query_update = $query_update."delivery_date='$todaysdate', "; }
$query_update=$query_update."status='$New_Status', next_task='a', priority_level='0' where id=\"$IRS_id\"";
$sql_result = mysql_db_query("$db", $query_update);
$strmess = "UAT_date:$UAT_date\nRequired_Date:$Required_Date\ndel_date:$del_date\n\n";
$strmess = $strmess."Query = $query_update";
mail("$Initiator_Email","$mt",$strmess,$headers);
The status is always marked correctly
The priority level is always marked correctly
The other 4 fields UAT_date, required_date, delivery_date, next_task only get marked some of the time.
The mail I receive shows a query like below
update IRSRequest set UAT_date='2005-01-28', required_date='2005-01-28', delivery_date='2005-01-28', status='Completed', next_task='a', priority_level='0' where id="250"
The fields are set up as
status varchar(15)
required_date varchar(10)
delivery_date varchar(10)
UAT_date varchar(10)
next_task varchar(10)
Can anyone shed any light on this for me ????
It is definitely executing this bit of code, and I have all my DB connections working OK.