storing bzcompressed data in MySQL
| From: | Paul Chvostek | Date: | Sun, 13 Apr 2003 19:17:35 +0000 |
| Subject: | storing bzcompressed data in MySQL | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27058@lists.php.net to get a copy of this message | ||
I've got an automated system that will be storing text files of up to
about 20k. In peak times, I expect to have two to three million of
these text files "on demand", though in reality they'll be expired *way*
more often than they're referenced.
To save space, I'd like to store the text using bzcompress(), but when I
use a construct like this:
$q = "INSERT INTO item (bztext) ('" . bzcompress($text,9) . "')";
But running the query gets my mysql_error() results of
You have an error in your SQL syntax near '$¢icÍeÖ3 ÒmX®""
EèÓÊÊA*"("M0¤´è,¨
ÚP#®ïsÂüÞ´+Ò÷jW6%e VdÁ' at line 2
It seems that the bzcompressed data includes single (and double) quotes.
Is the solution here to encode everything using htmlspecialchars(), thus
using extra resources for both inbound and outbound data? Or will it
suffice to str_replace("'","''",bzcompress($text,9)) ? Are there
other
things that will break?
Or is there some other preferred method to ensure accurate storage of
blocks of binary data?
Thanks. :)
--
Paul Chvostek <paul@it.ca>
Operations / Abuse / Whatever
it.canada, hosting and development http://www.it.ca/