From e3801abaf41267cd9750b53c345cd7e41ff35d92 Mon Sep 17 00:00:00 2001 From: Hash Borgir Date: Wed, 14 Jun 2023 03:44:04 -0600 Subject: [PATCH] replacing } with \n properly --- TblEditor.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/TblEditor.php b/TblEditor.php index 70b9436..be82783 100644 --- a/TblEditor.php +++ b/TblEditor.php @@ -90,6 +90,9 @@ if ($cmd == "getTable") { // Iterate over the rows foreach ($rows as $row) { + + $row['String'] = str_replace('}', ' ', $row['String']); + $tableMarkup .= ""; $tableMarkup .= "{$row['rowid']}"; @@ -120,8 +123,14 @@ if ($cmd == "getTable") { if ($cmd == "update") { + + //ddump($_REQUEST); + + $string = str_replace('\n', '}', $_REQUEST['string']); + + $query = "UPDATE $tableName SET Key = ?, String = ? WHERE Key = ?"; - PDO_Execute($query, [$_REQUEST['key'], $_REQUEST['string'], $_REQUEST['key']]); + PDO_Execute($query, [$_REQUEST['key'], $string, $_REQUEST['key']]); // Update the corresponding row in the text file $filePath = "{$_SESSION['tbl']}/$tableName.txt"; @@ -131,7 +140,7 @@ if ($cmd == "update") { $lineNumber = $_REQUEST['rowid']; // Update the line in the file with the new key and string values - $fileLines[$lineNumber - 1] = "{$_REQUEST['key']}\t{$_REQUEST['string']}\n"; + $fileLines[$lineNumber - 1] = "{$_REQUEST['key']}\t{$string}\n"; // Save the updated content back to the text file file_put_contents($filePath, implode("", array_filter($fileLines)));