Jump to content

When "warrior's" get inserted into database it comes out as "warrior\'s"


TeddyKiller

Recommended Posts

      $insert['name'] = html_entity_encode($_POST['name'], ENT_QUOTES);

      $query = $db->autoexecute('items', $insert, 'INSERT');

 

Then when I call it to be displayed.. do..

html_entity_decode($row['name'], ENT_QUOTES);

 

Correct? - When I say "comes out" I mean, it gets inserted in the database as "warrior\'s" even though we type it as "warrior's" in the textbox.

Link to comment
Share on other sites

 

Eh, not the best practice.  You should instead use whatever escape mechanism is appropriate for the db you're using (e.g., mysql_real_escape_string).

 

That wasn't intended to sanitize the input data. It was simply a solution to his problem (i.e. removing the slashes from his input string).

 

mysql_real_escape_string() prepends backslashes, which I assume he was already using since he was trying to remove the backslashes from his quotes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.