Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5384C632DFD for ; Sun, 22 Nov 2009 15:45:00 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36730-09 for ; Sun, 22 Nov 2009 19:44:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail24.svc.cra.dublin.eircom.net (mail24.svc.cra.dublin.eircom.net [159.134.118.53]) by mail.postgresql.org (Postfix) with SMTP id D5B42632D7E for ; Sun, 22 Nov 2009 15:44:51 -0400 (AST) Received: (qmail 6245 messnum 14390403 invoked from network[86.40.238.51/86-40-238-51-dynamic.b-ras3.mvw.galway.eircom.net]); 22 Nov 2009 19:44:49 -0000 Received: from 86-40-238-51-dynamic.b-ras3.mvw.galway.eircom.net (HELO ?127.0.0.1?) (86.40.238.51) by mail24.svc.cra.dublin.eircom.net (qp 6245) with SMTP; 22 Nov 2009 19:44:49 -0000 Message-ID: <4B0994B0.9040406@iol.ie> Date: Sun, 22 Nov 2009 19:44:48 +0000 From: Raymond O'Donnell Reply-To: rod@iol.ie User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Sylvain Racine CC: pgsql-php@postgresql.org Subject: Re: Use of pg_escape_string() References: In-Reply-To: X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 091122-0, 22/11/2009), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200911/2 X-Sequence-Number: 4094 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