Make Y! Your Homepage
  1. Home >
  2. All Categories >
  3. Computers & Internet >
  4. Programming & Design >
  5. Resolved Question
Joed Joed
Member since:
January 12, 2008
Total points:
394 (Level 2)

Resolved Question

Show me another »

How can I save a URL with backslashes in mySql database?

I have this problem in storing URL in mySql. I tried to put the URL which came from the file chooser into a String variable. When I printed it, it seemed to be ok but when I saved it in the database, all the backslashes were gone. What should I do? Please help me. Thanks in advance.
Some Guy by Some Guy
Member since:
June 18, 2008
Total points:
24,316 (Level 6)

Best Answer - Chosen by Voters

Escape them by *adding* a backslash:

  C:\\Documents and Settings\\blah\\blah blah
67% 2 Votes

There are currently no comments for this question.

Other Answers (3)

  • just "JR" by just "JR"
    A Top Contributor is someone who is knowledgeable in a particular category.
    Member since:
    July 26, 2006
    Total points:
    72,772 (Level 7)
    Badge Image:
    A Top Contributor is someone who is knowledgeable in a particular category.
    Use these three Php functions:
    addslashes, stripslashes and str_replace
    Use stripslashes first ( "\\\" -> "\\" )
    To remove escaped backslashes, use str_replace("\\" ,"", $string);
    Check viewing your table contents directly, then their output into a text on screen.
    0% 0 Votes
  • Greg P by Greg P
    Member since:
    April 06, 2007
    Total points:
    1,107 (Level 3)
    check your table, if you are storing URLs, you will probably want to use something like varchar (50)

    You may be using a table that doesn't accept those characters.
    33% 1 Vote
  • acb29 by acb29
    Member since:
    March 29, 2006
    Total points:
    3,340 (Level 4)
    Use mysql_real_escape_string() function clean strings of SQL syntax before inserting them into my database.
    0% 0 Votes

Answers International

Yahoo! does not evaluate or guarantee the accuracy of any Yahoo! Answers content. Click here for the Full Disclaimer.

Help us improve Yahoo! Answers. Send Feedback