I upload a symbol '<' to database getting the symbol from a <div value = '<'>
. And when I watch the database result, there displayed a html entity <
. And I tried html_entity_decode()
, but it doesn't work.
Here is my code div:
<option value = "<" <?php if ( ! empty ( $dwwp_stored_meta['operator-post'] ) ) {
if ( $dwwp_stored_meta['operator-post'][0]== '<' )
echo 'selected = "selected"';
} ?>> < </option>
And here is the update function:
update_post_meta( $post_id, 'operator', sanitize_text_field(html_entity_decode($_POST[ 'operator' ],ENT_QUOTES,"UTF-8" )));
But the function upload a html entity, how can I solve it? thx a lot.
sanitize_text_field says: "Converts single < characters to entities"
So, just don't use that function. It has nothing to do with SQL anyway - it is meant for outputting to a HTML text field, not for SQL text fields.
Use built in PHP utf8-encode function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.