+ Post New Thread
Results 1 to 6 of 6
Web Development Thread, Remove / before ' - PHP in Coding and Web Development; How do i remove the / that appears when theres a ' in php. Very brief but i dont think ...
  1. #1

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20

    Remove / before ' - PHP

    How do i remove the / that appears when theres a ' in php.
    Very brief but i dont think i can tell you anything else,

    Thanks
    Jack Dunn

  2. #2

    Join Date
    Jul 2007
    Location
    Devon
    Posts
    233
    Thank Post
    8
    Thanked 9 Times in 8 Posts
    Rep Power
    16
    stripslashes( $str );


    ?

  3. #3


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,475
    Thank Post
    867
    Thanked 850 Times in 672 Posts
    Rep Power
    196
    You may have a deeper issue - the \ is an escape character, and it is there to stop the ' or " or any other "special" character being taken literally. Just removing the \ *may* not be a great idea.

    What exactly is it you are trying to do?
    You should ask yourself:
    * Do i need to use this data in escaped form
    * What is escaping the data, and can i stop it happening if i don't need it?

    Long time since i've done PHP, but ISTR there being a few php.ini options regarding escaping - anyone refresh my memory?

  4. #4
    Jona's Avatar
    Join Date
    May 2007
    Location
    Cranleigh
    Posts
    470
    Thank Post
    14
    Thanked 50 Times in 48 Posts
    Rep Power
    23
    stripslashes() should do it as always more info on php.net - http://uk2.php.net/manual/en/function.stripslashes.php , but pay attention to what Tom said especially if your dealing with a database as you may be opening yourself up to SQL injection attack.

    Cheers
    Jona

  5. #5

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,892
    Thank Post
    518
    Thanked 2,494 Times in 1,935 Posts
    Blog Entries
    24
    Rep Power
    839
    The normal way of handling escaping is to allow the data to be be stored with the slashes in place and only remove them when outputting on screen.

  6. #6
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,791
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    118
    Quote Originally Posted by Jona View Post
    stripslashes() should do it as always more info on php.net - http://uk2.php.net/manual/en/function.stripslashes.php , but pay attention to what Tom said especially if your dealing with a database as you may be opening yourself up to SQL injection attack.
    Just as a note on that... One trick that often works is to do a preg_replace() on any input and replace ' with '' (that's two single quotes btw!) which will stop any injection routines and is the same as an escaped ' in MySQL.

    For more info' this ref is quite useful.

    http://dev.mysql.com/doc/refman/5.0/...ng-syntax.html

    There are several ways to include quote characters within a string:

    *

    A “'” inside a string quoted with “'” may be written as “''”.
    *

    A “"” inside a string quoted with “"” may be written as “""”.
    *

    Precede the quote character by an escape character (“\”).
    *

    A “'” inside a string quoted with “"” needs no special treatment and need not be doubled or escaped. In the same way, “"” inside a string quoted with “'” needs no special treatment.

SHARE:
+ Post New Thread

Similar Threads

  1. GPO to remove printer properites
    By eejit in forum Windows
    Replies: 15
    Last Post: 21st May 2009, 02:27 PM
  2. Remove Restart Option
    By AnnDroyd in forum Windows
    Replies: 7
    Last Post: 20th December 2007, 02:01 PM
  3. Remove CC3 without rebuild
    By meastaugh1 in forum Network and Classroom Management
    Replies: 7
    Last Post: 29th January 2007, 12:57 PM
  4. Remove DeepFreeze
    By indiegirl in forum How do you do....it?
    Replies: 4
    Last Post: 13th December 2006, 03:15 PM
  5. Bulk Remove Users from OU?
    By indiegirl in forum How do you do....it?
    Replies: 11
    Last Post: 17th August 2006, 03:23 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •