• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

'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')
0
TSFLLC
Asked:
TSFLLC
  • 2
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now