Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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(
                            '%s',
                            '%s',
                            '%s',
                            '%s',
                            '%s',
                            '%s'
                            );
                $wpdb->insert( $table, $data, $format);
share|improve this question
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.