Wrox Programmer Forums
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 23rd, 2004, 03:18 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default strings

hello all, the question might be really easy but here's the deal... i have a form which contains the "description" field which is a textarea.... if i include a character which is single quote or a double quote, and submit the form this becomes something like this

description provided:
what's up

when submitted:
what\'s up

that data is submitted into database... now if i decide to read it from db, it will be written as:

what\'s up

what i want to do is to get rid of the backward slash character... can someone tell me if there is a php function which does that?


the genuine genius
www.campusgrind.com - college portal
Old April 23rd, 2004, 03:59 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts

Yes. look at addslashes() and stripslashes().


Since PHP can be configured to automatically addslashes() to incoming text (which your PHP seems to do), you can write a wrapper function around stripslashes() that only strips the slashes from incoming form input if PHP automatically added them.

More info on this here:

Take care,

Old May 17th, 2004, 06:15 AM
Authorized User
Join Date: Apr 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

Exactly as nikolai suggested, excetp that I believe that this is not Php being configured to addslashes, but rathe the server uses MagicQuotesOn. Run phpinfo() and look.
If you wish to distribute the code you should detect the server settings and respond appropriatelly.


Similar Threads
Thread Thread Starter Forum Replies Last Post
strings RoniR VB.NET 2002/2003 Basics 1 May 4th, 2007 02:55 PM
strings bschleusner C# 2005 3 February 27th, 2007 11:46 PM
Strings ldoodle Classic ASP Basics 0 June 28th, 2005 09:26 AM
strings... slowhand BOOK: ASP.NET Website Programming Problem-Design-Solution 1 January 5th, 2004 06:27 AM
strings slowhand SQL Server 2000 1 January 5th, 2004 12:20 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.