Skip site navigation (1) Skip section navigation (2)

Re: [Q] storing JSON, problem with 'escapes'

From: "V S P" <toreason(at)fastmail(dot)fm>
To: "Chris" <dmagick(at)gmail(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: [Q] storing JSON, problem with 'escapes'
Date: 2008-11-21 07:43:56
Message-ID: 1227253436.22606.1285996237@webmail.messagingengine.com (view raw or flat)
Thread:
Lists: pgsql-php
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(at)fastmail(dot)fm

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


In response to

pgsql-php by date

Next:From: Andrew McMillanDate: 2008-11-21 10:28:46
Subject: Re: [Q] storing JSON, problem with 'escapes'
Previous:From: ChrisDate: 2008-11-21 07:17:59
Subject: Re: [Q] storing JSON, problem with 'escapes'

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group