I am trying to save a PDF file as blob im MySQL database. The problem takes place when I save the file into the database it lays out a syntax error so I had to add slashes to it.
$user_id = sanitizeInt ($user_id );
$file_content = addslashes ($file_content);
$query = "INSERT INTO `locker`.`files`(`id`, `user_id`, `file_name`, `file_content`) VALUES (NULL, $user_id, 'some_name.pdf', '$file_content');";
But when I want to download it later on I do the opposit. I query then use remove slahes
$query = "SELECT `files`.`file_content`, `files`.`file_name` FROM `files` WHERE `files`.`id` = $id LIMIT 0 , 1";
$record = mysql_fetch_array($result, MYSQL_ASSOC);
return stripslashes($record["file_content"]);
When I output the PDF I get an empty file.
I have just solved the problem.
I removed stripslashes and it worked as a charm.