X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3DEEAD1B43C for ; Mon, 15 Dec 2003 16:43:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75466-02 for ; Mon, 15 Dec 2003 12:43:36 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 49669D1B479 for ; Mon, 15 Dec 2003 12:43:26 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hBFGgQ8q001967; Mon, 15 Dec 2003 09:42:27 -0700 (MST) Date: Mon, 15 Dec 2003 09:25:41 -0700 (MST) From: "scott.marlowe" To: Tino Wildenhain Cc: Nathaniel Price , Subject: Re: [GENERAL] Reordering results for a report In-Reply-To: <3FDD789A.7060201@wildenhain.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/31 X-Sequence-Number: 2477 On Mon, 15 Dec 2003, Tino Wildenhain wrote: > Hi Scott, > > scott.marlowe schrieb: > [...] > > > > print "?orderby=".$flds[$i]."moreurlstuffhere???"; > > > > Then, if the orderby is set when you build your query, just append it: > > > > if (isset($orderby)){ > > $query.= "order by ".$orderby" > > } > > > > Add some directional control: > > > > if (isset($dir)){ > > if ($dir=="down") $query.=" DESC"; > > } > > > [...] > > This leads to a nice SQL-injection posibility. > At least it has to made sure that no illegal > data can be transported via $orderby Actually, the $flds[] array var is internally generated, and you'll notice that orderby is NOT a PHP var, but a field name. Good point though, lots of folks "trust" user input without paying attention to injection issues, which is one reason I always setup servers with magic quotes on. :-)