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.

Use stripslashes() before inserting the data into the database.

 

http://php.net/manual/en/function.stripslashes.php

 

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).

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.