0

I have a string which is a path and is a variable in which I have to save in my database. But the path is

C:\foldera\folderb\folder1\folder2

and obviously I need it to be

C:\\foldera\\folderb\\folder1\\folder2

for the insertion in database of mysql.

Please help me find the solution. I tried str_replace but it won't work. Thanks in advance.

Rizier123
  • 58,877
  • 16
  • 101
  • 156
Adnama
  • 172
  • 2
  • 12

1 Answers1

-1

The function you are looking for is addslashes($string); This function adds the slashes to turn your string into the string you are looking for. But if you are planning on using it as a parameter in an SQL statment you want to use mysqli_real_escape_string()

Also use single quotes in the string in order for addslashes() to work properly. double quotes will parse it as \f not just '\'.

Richard Christensen
  • 2,046
  • 17
  • 28