Re: problem with single quote in postgres 8.3.5

From: David Fetter <david(at)fetter(dot)org>
To: hugocoolens <hugocoolens(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with single quote in postgres 8.3.5
Date: 2009-03-07 18:02:22
Message-ID: 20090307180222.GA11100@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2009-03-07 19:40:50 Re: VACUUM
Previous Message Raymond O'Donnell 2009-03-07 17:50:43 Re: problem with single quote in postgres 8.3.5