X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DFD01528AC for ; Fri, 27 May 2005 15:15:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81185-07 for ; Fri, 27 May 2005 18:14:52 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 60E93528A7 for ; Fri, 27 May 2005 15:14:50 -0300 (ADT) Received: (qmail 10188 invoked by uid 500); 27 May 2005 18:13:41 -0000 Date: Fri, 27 May 2005 13:13:41 -0500 From: Bruno Wolff III To: operationsengineer1@yahoo.com Cc: Ed Finkler , Volkan YAZICI , pgsql-php@postgresql.org Subject: Re: Effectiveness of pg_escape_string at blocking SQL injection Message-ID: <20050527181341.GA9856@wolff.to> Mail-Followup-To: Bruno Wolff III , operationsengineer1@yahoo.com, Ed Finkler , Volkan YAZICI , pgsql-php@postgresql.org References: <20050527172552.50460.qmail@web52409.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050527172552.50460.qmail@web52409.mail.yahoo.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/41 X-Sequence-Number: 3155 On Fri, May 27, 2005 at 10:25:52 -0700, operationsengineer1@yahoo.com wrote: > > bruno and all... what are bind parameters? how can i > avoid building sql from user input when my sql depends > on user input? You leave place holders in the SQL string to be replaced by parameters passed separately. You don't need to do any escaping of the parameters when passed this way. Here is a snipet of perl code that does this: $rows = $dbh->do(<<'EOF', INSERT INTO detail (day, amount, comment, category, cat_type) SELECT ?, ?, ?, id, cat_type FROM category WHERE id = ? EOF {}, param('day'), param('amount'), param('comment'), param('category'));