Re: problem with single quote in postgres 8.3.5 - Mailing list pgsql-general

From David Fetter
Subject Re: problem with single quote in postgres 8.3.5
Date
Msg-id 20090307180222.GA11100@fetter.org
Whole thread Raw
In response to problem with single quote in postgres 8.3.5  (hugocoolens <hugocoolens@gmail.com>)
List pgsql-general
On Sat, Mar 07, 2009 at 05:53:21AM -0800, hugocoolens wrote:
> I have a little php-script to  help me learn foreign languages
> In my php-code I have the following line:
> $query="update wordlist set known=true where dutch='".$preceding."'";

With this kind of line, you are inviting an SQL injection as
illustrated below:

http://xkcd.com/327/

Instead, use pg_prepare() and pg_execute() for this kind of thing.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: problem with single quote in postgres 8.3.5
Next
From: John R Pierce
Date:
Subject: Re: VACUUM