Updatig Text Fields

wxdqz

New Member
Hiya,

I've got a small problem. I a have a PHP script which updates, a record in a MySQL database.

The script updates one varchar field and appends two text fields. The problem is with these appends. Sometimes one of them works and sometimes it doesn't. Has anyone experienced this?

I've trieds extracting the data from the record, appeding the PHP variable I extracted it to and then doing a straight update, but this was updating the record erratically. Sometimesa it would, other times it would throw up MySQL error 0. I've now settled on using concat to append the fields, I still get the erratic behaviour, but without any MySQL error. I've tried seperating all three updates into seperates mysql_query statements, but that doesn't seem to have helped.

Help !!!!! An extract from my code is below.

Nick Gushlow

----------oOo----------
if ($Submit) {
// check status of record
if (($row[status] > 1) && ($row[status] < 5)) {
// append log with new entry short log, log and date
// get date
$current_date = date("Y-m-d");
// get current short_log
$current_short_log = $row[short_log];
// get current log
$current_log = $row[full_log];
// update short desc
$new_short_log = "\\n\\n----------oOo----------\\n".
$current_date." - ".$desc;
// update full log
$new_full_log = "\\n\\n----------oOo----------\\n".
$current_date." - ".$user." - ".$log;

// update table set field = concat(field, "some new string) where id = 4;
$insert_result = mysql_query("UPDATE calls SET short_log = concat(short_log, '$new_short_log') WHERE dws_call_id = '$call_id'");
$insert_result2 = mysql_query("UPDATE calls SET full_log = concat(full_log, '$new_full_log') WHERE dws_call_id = '$call_id'");
$insert_result3 = mysql_query("UPDATE calls SET status = '$status' WHERE dws_call_id = '$call_id'");
// $insert_result = mysql_query("UPDATE calls SET short_log='$new_short_log', status='$status' WHERE dws_call_id='$call_id'");
// $insert_result2 = mysql_query("UPDATE calls SET full_log='$new_full_log' WHERE dws_call_id='$call_id'");

if ($insert_result) {
if ($insert_result2) {
if ($insert_result3) {
$error = 30;
echo "<script language=\"JavaScript\"> ";
echo "location='main.php';";
echo "</script>";
exit;
} else {
// Data insertion error!!!!
$error = 999;
echo "<script language=\"JavaScript\"> ";
echo "location='main.php';";
echo "</script>";
exit;
}
}
// Data insertion error!!!!
$error = 999;
echo "<script language=\"JavaScript\"> ";
echo "location='main.php';";
echo "</script>";
exit;
}
} else {
$error = 31;
echo "<script language=\"JavaScript\"> ";
echo "location='main.php';";
echo "</script>";
exit;
}
}
 
Back
Top