From: Raymond O'Donnell <rod@iol.ie>
To: Sylvain Racine <syracine@sympatico.ca>
Cc: pgsql-php@postgresql.org
Subject: Re: Use of pg_escape_string()
Date: Sun, 22 Nov 2009 19:44:48 +0000
Message-ID: <4B0994B0.9040406@iol.ie> (raw)
In-Reply-To: <BLU0-SMTP3034F7FE7C5F0BEA0009A5FD9F0@phx.gbl>
References: <BLU0-SMTP3034F7FE7C5F0BEA0009A5FD9F0@phx.gbl>
On 22/11/2009 19:22, Sylvain Racine wrote:
> Hello,
>
> I use to hear about to escape every variables who come from user in PHP.
> Most programmers around me use MySQL with mysql_escape_string(). Because
> I program with PostgreSQL, I take advantage to use pg_escape_string().
> Everything goes well, up I entered data with apostrophe(').
> pg_escape_string() escapes my apostrophe with another apostrophe ('').
> My data are well store in database. No error... except that appears a
> double apostrophe. This is not what I want.
>
> Maybe something is wrong in my program. Here is a sample of what I use
> to store data in table "personnes" which have two columns: firstname,
> lastname. I remove database connection and construction of objects
> Minute and Personnes.
Where is the INSERTed data coming from? - Is it coming from data
submitted by GET or POST? - if so, is magic_quotes_gpc turned on? If it
is, this could explain what you're seeing.
BTW, it's much better to use parametrised queries - look up
pg_query_params in the PHP docs. This looks after all quoting for you
automatically, and prevents SQL injection attacks.
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie
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: rod@iol.ie, syracine@sympatico.ca
Subject: Re: Use of pg_escape_string()
In-Reply-To: <4B0994B0.9040406@iol.ie>
References: <BLU0-SMTP3034F7FE7C5F0BEA0009A5FD9F0@phx.gbl> <4B0994B0.9040406@iol.ie>
* 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