'C:\Folder\File.pdf' missing slashes using Insert

New to MySQL, but not that new to SQL statements

First time I've needed to populate a field with a folder/file path.  Why would the slashes in the insert below be missing?

INSERT INTO `web`.`notice_board` (nb_sr_no, nb_Img_path, nb_File_path)
VALUES (227, 'C:\Folder\My.pdf', 'My.pdf')
TSFLLCAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Muhammad WasifCommented:
In MySQL statements \ is used to escape a character e.g. to save single quote, double quote or any other special character (for more details look at http://dev.mysql.com/doc/refman/5.1/en/string-literals.html). To save \ in the data, you need to use double \ like below

INSERT INTO `web`.`notice_board` (nb_sr_no, nb_Img_path, nb_File_path) 
VALUES (227, 'C:\\Folder\\My.pdf', 'My.pdf')

Open in new window


In PHP, you can use addslashes() function too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TSFLLCAuthor Commented:
Excellent!  This is exactly what I needed.  I should have known a double \\ would take care of it.  Thanks for the link.
0
Muhammad WasifCommented:
You are welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.