Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 374887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:26:57+00:00 2026-05-12T14:26:57+00:00

I need to store relative path of a document into a MySQL table. The

  • 0

I need to store relative path of a document into a MySQL table. The problem is that when I insert a string of this form:

$urlPath ='\abc\def\fg.jpg'

into the relevant column, what I get is, I have all the slash '\' strip off, with an unknown symbol in front of all the text. So the result in the MySQL table is something like this:

'(weird symbol)abcdeffg.jpg'

As you can see, this kind of data is useless. Any idea how to fix this?

Edit: I tried $urlPath ="\\abc\\def\\fg.jpg" and $urlPath ='\\abc\\def\\fg.jpg', still I got gibberish..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:26:57+00:00Added an answer on May 12, 2026 at 2:26 pm

    You need to escape it twice, first for PHP because the \ character has a special meaning:

    From the docs:

    To specify a literal backslash before
    a single quote, or at the end of the
    string, double it (\)

    $urlPath ='\\abc\\def\\fg.jpg';
    

    Then you need to escape it again for MySQL because the literal string now contains ‘s which also has special meaning to MySQL.

    mysql_real_escape_string() calls
    MySQL’s library function
    mysql_real_escape_string, which
    prepends backslashes to the following
    characters: \x00, \n, \r, , ‘, " and
    \x1a.

    $databaseUrlPath = mysql_real_escape_string($urlPath);
    

    If you don’t want to depend on MySQL, you can use addslashes instead:

    Returns a string with backslashes
    before characters that need to be
    quoted in database queries etc. These
    characters are single quote (‘),
    double quote ("), backslash () and
    NUL (the NULL byte).

    $databaseUrlPath = addslashes($urlPath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use Server.MapPath() to combine some files path that I store in
I have id values for products that I need store. Right now they are
I need to store a lot of data coming in from a server into
I need to store a file, such that my ASP.Net MVC app can access
This is my class file which contains variables which I need to store. public
I have a need for a high-performance string hashing function in python that produces
Is it possible to specify a relative connection string for an AzMan XML store?
I need to store various info about some movies, books, games, and maybe other
I need to store IP address in the most compact way possible, searching is
I need to store up to tens or even hundreds of millions of pieces

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.