arrays - PHP: Getting sqlite_escape_string to work correctly. Allow apostrophes to be saved -
the problem: when editing language, cannot add apostrophe text field. if do, record not saved new edits.
the goal: upon editing, allow these edits include apostrophes , save correctly.
currently: can use numbers, letters, , symbols, not apostrophes.
i tried thinking work, no avail:
$val = (isset($airport_info[$airport_key])) ? sqlite_escape_string($airport_info[$airport_key]) : "";
below original code.
<div class="inline_div_right"> <table> <?php $j=1; $some_langs_hidden = 0; foreach(array_keys($fields) $airport_key) { if(is_numeric($airport_key)) continue; if(preg_match("/name_/", $airport_key)) { $lang_iso = substr($airport_key, -2); $val = (isset($airport_info[$airport_key])) ? $airport_info[$airport_key] : ""; $row_visibility = ""; if(!in_array($lang_iso, $used_languages)) { $row_visibility = "hidden_class"; $some_langs_hidden = 1; } $row_class = ($j%2 == 0) ? "shade1" : "shade2"; ?> <tr class="<?php echo $row_class.' '.$row_visibility; ?>"> <td class='ca_left_column'><?php echo $languages[$lang_iso]; ?></td> <td><input type='textfield' id='<?php echo $airport_key; ?>' name='<?php echo $airport_key; ?>' class='textfield_class_large' onkeypress="hideerrormsg(); entersubmission(event, fcn)" value='<?php echo $val; ?>'></td> </tr> <?php $j++; } } ?> </table> </div>
any input appreciated.
defined function:
function sqlsecurity($sql_string) { $return_string = sqlite_escape_string($sql_string); $val = stripslashes($return_string); return $val; }
called function in our processajax.php file, main line being:
$query .= ", name_$lang_code = '".sqlsecurity($_request["name_$lang_code"])."'";
then view value in textfield:
value="<?php echo str_replace('"', '"', $val); ?>"
any constructive criticism appreciated. correct values being returned in database , displayed correctly in browser.
Comments
Post a Comment