pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mariusz Pękala <skoot@qi.pl>
To: pgsql-php@postgresql.org
Subject: Re: Select Where using character varying ??
Date: Tue, 3 Oct 2006 22:03:53 +0200
Message-ID: <20061003200353.GA8719@cthulhu.sdi.tpnet.pl> (raw)
In-Reply-To: <5887d1f40610030557q6e3d097dl6b72f47e2b289185@mail.gmail.com>
References: <BAY116-F1074C7ACE9E04AA4A018B88F1C0@phx.gbl>
	<452219C8.4010200@tiggs.net>
	<5887d1f40610030557q6e3d097dl6b72f47e2b289185@mail.gmail.com>

> I think you should try:
> $Sem_No = pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE name 
> =\"$Sem\"");

Double quotes are for quoting column names, not string constants.

> $Sem_No = pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE name 
> ='$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 ''='

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.


-- 
Ceterum censeo Internet Explorer esse delendam.

view thread (5+ messages)  latest in thread

Message-ID: <20061003200353.GA8719@cthulhu.sdi.tpnet.pl>
Permalink:  ../20061003200353.GA8719@cthulhu.sdi.tpnet.pl/
Also on:    postgresql.org/message-id/20061003200353.GA8719@cthulhu.sdi.tpnet.pl

 · 

reply

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: skoot@qi.pl
  Subject: Re: Select Where using character varying ??
  In-Reply-To: <20061003200353.GA8719@cthulhu.sdi.tpnet.pl>
  References: <BAY116-F1074C7ACE9E04AA4A018B88F1C0@phx.gbl> <452219C8.4010200@tiggs.net> <5887d1f40610030557q6e3d097dl6b72f47e2b289185@mail.gmail.com> <20061003200353.GA8719@cthulhu.sdi.tpnet.pl>

* 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