Results 1 to 4 of 4

Thread: How to remove apostrophes in PHP

  1. #1
    Join Date
    Feb 2008
    Posts
    624

    How to remove apostrophes in PHP

    I am having a database created in PHP. Many of the tables in it contains apostrophes. I want to remove that slashes in my result and here lies my problem.

    Example: for "I am under the tree."
    I get the result: "I'm in l \"

    I tried the addslashes but it changes nothing.

    PHP Code:
    <input type='text' name='description4' size='100' value='".addslashes($    
    data['
    description4_information'])."' /> 

  2. #2
    Join Date
    May 2008
    Posts
    945

    Re: How to remove apostrophes in PHP

    Quote Originally Posted by Sean J View Post
    I tried the addslashes but it changes nothing.

    PHP Code:
    <input type='text' name='description4' size='100' value='".addslashes($    
    data['
    description4_information'])."' /> 
    Here lies your actual problem. Basically addslashes adds slashes whereas stripslashes removes slashes. So, in short, use stripslashes rather than addslashes.

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to remove apostrophes in PHP

    You put this:

    value="<?php echo $data['description4_information']"' />

    or begin with a echo '... value = ".addslashes ($data[' description4_information'])."' /> ', do this:
    echo "<input type='text' name='description4' size='100' value=".$data['description4_information'])." />";

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: How to remove apostrophes in PHP

    Quote Originally Posted by Sean J View Post
    PHP Code:
    <input type='text' name='description4' size='100' value='".addslashes($    
    data['
    description4_information'])."' /> 
    This is happening because you are using
    value='
    When the compiler encounters an apostrophe, it assumes that this is the end of the statement. In short your text get escapes with htmlspecialchars () like apostrophe, slashes, etc. If you don't want to give it any value then better don't use it.

Similar Threads

  1. Replies: 4
    Last Post: 11-09-2011, 10:18 AM
  2. Replies: 1
    Last Post: 13-04-2011, 06:24 PM
  3. Found Tango in add/remove programs unable to remove it
    By Sarasi in forum Windows Software
    Replies: 6
    Last Post: 17-07-2010, 02:01 PM
  4. Replies: 5
    Last Post: 08-07-2010, 04:48 AM
  5. Replies: 2
    Last Post: 19-01-2007, 12:07 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,387,562.92063 seconds with 16 queries