Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 10F309FB30E for ; Tue, 3 Oct 2006 17:10:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 19319-10 for ; Tue, 3 Oct 2006 17:09:57 -0300 (ADT) X-Greylist: delayed 00:06:40.362984 by SQLgrey- Received: from pb78.olsztyn.sdi.tpnet.pl. (pb78.olsztyn.sdi.tpnet.pl [213.76.235.78]) by postgresql.org (Postfix) with ESMTP id 8EF2D9FB24C for ; Tue, 3 Oct 2006 17:09:56 -0300 (ADT) Received: (qmail 8957 invoked by uid 1000); 3 Oct 2006 22:03:53 +0200 Date: Tue, 3 Oct 2006 22:03:53 +0200 From: Mariusz =?iso-8859-2?Q?P=EAkala?= To: pgsql-php@postgresql.org Subject: Re: Select Where using character varying ?? Message-ID: <20061003200353.GA8719@cthulhu.sdi.tpnet.pl> Mail-Followup-To: pgsql-php@postgresql.org References: <452219C8.4010200@tiggs.net> <5887d1f40610030557q6e3d097dl6b72f47e2b289185@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: <5887d1f40610030557q6e3d097dl6b72f47e2b289185@mail.gmail.com> User-Agent: Mutt/1.5.11 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/4 X-Sequence-Number: 3604 --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > I think you should try: > $Sem_No =3D pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE name=20 > =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=20 > =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. --=20 Ceterum censeo Internet Explorer esse delendam. --9amGYk9869ThD9tj Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFIsIpsnU0scoWZKARAgb7AKDWyO7fVVo8eNHh2rlmAUPvnLObzgCeIlyl jMW3o/OJ7EUP2sZIV9f2NVA= =duCf -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--