From: | "Joe Conway (wwc)" <jconway(at)cox(dot)net> |
---|---|
To: | "Thomas T(dot) Thai" <tom(at)minnesota(dot)com> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: OK got it, BYTEA, PHP, Storing Images |
Date: | 2002-01-18 21:23:26 |
Message-ID: | 3C48924E.2040905@cox.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thomas T. Thai wrote:
> if you look at the decode function, i had to put those 'search' strings in
> single quotes. i honestly don't know why it works with 5 backslashes
> there. maybe someone can figure this out.
>
> to encode for bytea:
>
> function encodeByteA($binData) {
> // \000 = 00 = NULL, \012 = 10 = VerticalTab,
> // \047 = 39 = Single Quote, \134 = 92 = backslash
>
> $search = array(chr(0), chr(10), chr(39), chr(92));
> $replace = array("\\\\000", "\\\\012", "\\\\047", "\\\\134");
> $binData = str_replace($search, $replace, $binData);
> return $binData;
> }
Thanks!
BTW, later testing showed that escaping chr(10) was really unnecessary.
>
> to decode for bytea:
>
> function decodeByteA($binData) {
Why the decode function -- I thought stripcslashes() worked OK?
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Cornelia Boenigk | 2002-01-18 21:35:35 | Re: Need book on PHP and PostgreSQL |
Previous Message | Andrew Sullivan | 2002-01-18 21:07:44 | Re: large file limitation |