pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: V S P <toreason@fastmail.fm>
To: Chris <dmagick@gmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: [Q] storing JSON, problem with 'escapes'
Date: Fri, 21 Nov 2008 02:43:56 -0500
Message-ID: <1227253436.22606.1285996237@webmail.messagingengine.com> (raw)
In-Reply-To: <492660A7.3060008@gmail.com>
References: <1227250475.15555.1285991741@webmail.messagingengine.com>
	<492660A7.3060008@gmail.com>

hi,
magic_quotes_gpc is on,
however, the data (the strings) do not come from HTTP protocol
or web pages, they come from STDIN (using popen) when invoking
another program.

So, at the end of the process I have

"if( js_iop_lt(a,b) ){ VLADIKVLADIKVLADIKVLADIK(\"b2122\") ;}"

and then I prepare an SQL statement and use bindParams
to bind the string like the above to the Insert statement
and I know 100% that the string has single backslash (which is
how I want it to be stored -- because I want to stored as valid
JSON to be read by non-php programs).

But I am guessing something adds another backslash slash.
after I bind the string to the insert (and I have no way to undo
that because there is mechanism to get into the internal PDO 
structures to massage the values of the bound variables).


Now, when I check what's stored in the database -- the single slash
is stored -- which is correct (I think... I do not have the code to
read the data back in yet).

So it is almost like PosgreSQL ignores the second backslash, but
warns about it?...






> > For example here is a an array element
> > 
> > "if( js_iop_lt(a,b) ){ VLADIKVLADIKVLADIKVLADIK("b2122") ;}"
> > 
> > would get encoded in JSON as
> > 
> > "if( js_iop_lt(a,b) ){ VLADIKVLADIKVLADIKVLADIK(\"b2122\") ;}"
> 
> Is magic_quotes_gpc (or magic_quotes_runtime) on for the php server? 
> Check with a phpinfo() page.
> 
> If so, you'll need to "undo" that, see http://www.php.net/stripslashes 
> (inc. the recursive function stripslashes_deep).
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
-- 
  V S P
  toreason@fastmail.fm

-- 
http://www.fastmail.fm - Faster than the air-speed velocity of an
                          unladen european swallow




view thread (6+ messages)  latest in thread

Message-ID: <1227253436.22606.1285996237@webmail.messagingengine.com>
Permalink:  ../1227253436.22606.1285996237@webmail.messagingengine.com/
Also on:    postgresql.org/message-id/1227253436.22606.1285996237@webmail.messagingengine.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: toreason@fastmail.fm, dmagick@gmail.com
  Subject: Re: [Q] storing JSON, problem with 'escapes'
  In-Reply-To: <1227253436.22606.1285996237@webmail.messagingengine.com>
  References: <1227250475.15555.1285991741@webmail.messagingengine.com> <492660A7.3060008@gmail.com> <1227253436.22606.1285996237@webmail.messagingengine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox