note 13075 deleted from features.file-upload by irc-html

From: Date: Sat, 19 Jan 2002 20:33:31 +0000
Subject: note 13075 deleted from features.file-upload by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25353@lists.php.net to get a copy of this message
Corrupted binary data when extracting from MySQL with PHP 3.0.16 <br><br> In the site that I am developing you can access to a admin module where you can upload PDF files to a MySQL database. The idea is that a client of the system will put his user and password to see a page where are links to the PDFs that his profile allows him. When he clicks a link, a PHP script returns the header for PDF (using Header() ) and the binary data, so he can save it to disk and check it later. The code is something like this: <br><br> $header = "Content-type: application/pdf"; $res = mysql_query("SELECT data FROM pdf WHERE idpdf=1" , $con); if ($res) { while ($row = mysql_fetch_row($res)) { Header($header); print $row[0]; } } <br><br> This worked fine in home with PHP 4.0.4, but when I uploaded the script to my client ISP (PHP 3.0.16) it showed corrupted data. It took me a week to find out where the problem is; it was uploaded ok, it was correctly put in the DB, I could check it with mysql_fetch_lengths(), but when the script to show it executed print(), it appeared with extra slashes. The solution is to use stripslashes(), as in this line: <br><br> ... print stripslashes($row[0]); ... <br><br> The extra slashes appear only in this case, as I said PHP 4 was fien and another clients ISP which use PHP 3.0.9 had not problem. I dont know details about this ISP configuration, but take care if you find a similar problem.

« previous php.notes (#25353) next »