storing bzcompressed data in MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux