beginTransaction(); $sql = "UPDATE $DB.$tablename SET bend_state=?, update_log=? WHERE num=? LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $bend_state, PDO::PARAM_STR); $stmh->bindValue(2, $update_log, PDO::PARAM_STR); $stmh->bindValue(3, $num, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); $data = [ 'num' => $num, 'mode' => $mode ]; echo json_encode($data, JSON_UNESCAPED_UNICODE); } catch (PDOException $Exception) { $pdo->rollBack(); error_log("Database error: " . $Exception->getMessage()); // Log the error echo json_encode(['error' => 'Database error: ' . $Exception->getMessage()], JSON_UNESCAPED_UNICODE); } catch (Exception $e) { error_log("General error: " . $e->getMessage()); // Log general errors echo json_encode(['error' => 'General error: ' . $e->getMessage()], JSON_UNESCAPED_UNICODE); } ?>