Results 1 to 2 of 2

Thread: is addslashes() really needed?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Posts
    237

    is addslashes() really needed?

    hi all.. do you really need addslashes() to store data into mysql?
    Because I tried this:

    $item = "jim's";
    $item = addslashes($item);

    if I echo $item then $item is "jim\'s" then I store $item into mysql database table.

    But when I retrieve it using SELECT, even if I don't use stripslashes(), the result is "jim's" NOT "jim\'s". So what do I use the addslashes() for in the first place?

    thanks

  2. #2
    Member juanmf's Avatar
    Join Date
    Dec 2005
    Location
    Mordor
    Posts
    46

    Re: is addslashes() really needed?

    try using double addslashes. in linux "\" is used to "escape some character" to not being interpreted as special ones. so the "\" die in the process. if you want:
    "jim\'s" stored
    i think it should lok like:
    $item = "jim\\\'s" (\ to escape \ and \ to escape ')
    try it and tell me. becouse i didn´t tested. just a heartbit.
    edited one minute later
    OK i tryed it. it works.
    Last edited by juanmf; Mar 7th, 2006 at 09:35 AM.
    If an answer to your question has been helpful, then please, Rate it! where are u?
    On Staying Informed and Intellectual Self-Defense

    There's no way to be informed without devoting effort to the task, whether we have in mind what's happening in the world, or anything else. Understanding doesn't come free. But it's feasible for anyone who is part of a cooperative community -- Same holds for "intellectual self-defense."

    By Noam Chomsky

Posting Permissions

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



Click Here to Expand Forum to Full Width