I have a string, named $directory, which contains "C:\somedir\somesubdir\somefile".
I can do an echo $directory, and the string is outputted with the slashes in.
When I insert it into an MySQL table, the string loses the slash marks.
So "C:\somedir\somesubdir\somefile"
becomes "C:somedirsomesubdirsomefile".
my syntax is this:
$sql = "INSERT INTO mp3 (filename,directory) VALUES ('$filename','$directory')";

Anyone know what I need to do?

Thanks for any help 🙂

    $directory = str_replace("\", "\\", $directory);
    $sql = "INSERT INTO mp3 (filename,directory) VALUES ('$filename','$directory')";

    try that

      Your suggestion worked 🙂
      Althlugh I had to change:
      $directory = str_replace("\", "\\", $directory);
      to
      $directory = str_replace("\", "\\", $new_directory);

      otherwise the output came out funny....
      c:\mp3
      c:\\mp3
      c:\\\\mp3
      c:\\\\\\\\mp3

      Thanks though guys 🙂

        Write a Reply...