WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing an INSERT into a wordpress table and anything with an apostrophe is coming out

It\'s true

I tried using htmlspecialchars but I'm still getting the backslash.

Is there any way to write it so that the user sees

It's true

While the table in the database sees:

It\'s true

Below is my insert code:

global $wpdb;
                $table =    'wp_nc_location';
                $data =     array(
                            'name' => $name,
                            'street_no' => $street_number,
                            'street_name' => $street_name,
                            'city' => $city,
                            'province_state' => $province_state,
                            'postal_code' => $postal,
                            'country' => $country
                $format =   array(
                $wpdb->insert( $table, $data, $format);
share|improve this question
up vote 1 down vote accepted

When you retrieve the data make sure to call stripslashes, or stripslashes_deep if it's an array.

$name = stripslashes($name);
share|improve this answer

How are you writing and reading data exactly?

Are you using $wpdb->insert() method? Which you should be doing, it takes care of escaping.

share|improve this answer
I am using $wpdb->insert()...I wonder why it isn't removing the slashes? I'll post my actual code... – redconservatory Aug 20 '11 at 14:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.