Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 1DA819FB3DF for ; Tue, 3 Oct 2006 21:57:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 20300-08 for ; Wed, 4 Oct 2006 00:57:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from n007.sc1.cp.net (smtpout1434.sc1.he.tucows.com [64.97.157.134]) by postgresql.org (Postfix) with ESMTP id 39A5C9FB3E4 for ; Tue, 3 Oct 2006 21:57:21 -0300 (ADT) Received: from [10.0.0.48] (64.241.37.140) by n007.sc1.cp.net (7.2.069.1) (authenticated as rob@treat.com) id 4521FFEE0003D6BC; Wed, 4 Oct 2006 00:57:19 +0000 From: Robert Treat To: pgsql-php@postgresql.org Subject: Re: Select Where using character varying ?? Date: Tue, 3 Oct 2006 20:48:08 -0400 User-Agent: KMail/1.9.1 Cc: Mariusz =?utf-8?q?P=C4=99kala?= References: <5887d1f40610030557q6e3d097dl6b72f47e2b289185@mail.gmail.com> <20061003200353.GA8719@cthulhu.sdi.tpnet.pl> In-Reply-To: <20061003200353.GA8719@cthulhu.sdi.tpnet.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200610032048.09195.xzilla@users.sourceforge.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/5 X-Sequence-Number: 3605 On Tuesday 03 October 2006 16:03, Mariusz P=C4=99kala wrote: > > I think you should try: > > $Sem_No =3D pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE name > > =3D\"$Sem\""); > > Double quotes are for quoting column names, not string constants. > > > $Sem_No =3D pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE name > > =3D'$Sem'"); > > Better, but all strings, especially provided by some user, should be > treated by the function pg_escape_string. > > Consider that some user types in a form field a text like this: > > '; delete from seminar where ''=3D' > > When you add single quotes you get two valid queries. One of them is > what you would never want to be executed ;-) > > And, by the way - pg_exec is a deprecated name AFAIK. The new one is > pg_query. probably even better would be to use pg_prepare and pg_execute.=20 =2D-=20 Robert Treat Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL