Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-05-2009
Member
 
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'])."' /> 
Reply With Quote
  #2  
Old 11-05-2009
Member
 
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.
Reply With Quote
  #3  
Old 11-05-2009
Member
 
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'])." />";
Reply With Quote
  #4  
Old 11-05-2009
Member
 
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
Quote:
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to remove apostrophes in PHP"
Thread Thread Starter Forum Replies Last Post
Unable to remove internal devices from safely remove hardware list? LaMarcus Hardware Peripherals 4 11-09-2011 10:18 AM
How to remove External Drive from computer if 'Safely Remove Hardware' disappears Author Operating Systems 1 13-04-2011 06:24 PM
Found Tango in add/remove programs unable to remove it Sarasi Windows Software 6 17-07-2010 02:01 PM
Lightroom 2.6 Freezes - Folders with apostrophes the culprit Kaylynn Windows Software 5 08-07-2010 04:48 AM
Remove item from Safely Remove Hardware using registry? Pine Le XP Hardware 2 19-01-2007 12:07 AM


All times are GMT +5.5. The time now is 08:49 PM.