X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E7FB0D1B524 for ; Sun, 28 Sep 2003 13:54:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 56659-04 for ; Sun, 28 Sep 2003 10:53:47 -0300 (ADT) Received: from server.yourfacility.com (server.yourfacility.com [207.103.74.10]) by svr1.postgresql.org (Postfix) with SMTP id 842C9D1B4FC for ; Sun, 28 Sep 2003 10:53:43 -0300 (ADT) Received: (qmail 51708 invoked by uid 0); 28 Sep 2003 13:53:49 -0000 Received: from unknown (HELO ROD) (141.149.245.7) by server.yourfacility.com with SMTP; 28 Sep 2003 13:53:49 -0000 From: "Rod K" To: "Seader, Cameron" , Subject: Re: HTTP_AUTH and SQL WHERE Clause Date: Sun, 28 Sep 2003 09:53:35 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.local> Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/83 X-Sequence-Number: 2360 > $sql = ("SELECT * FROM tbl_authenticate WHERE username = > '$PHP_AUTH_USER' AND password = '$PHP_AUTH_PW'"); > There's no need for the parens around the quoted value. > The Problem is on the $sql line when i put in the string to do > the Query with the WHERE clause having the $HTTP_AUTH_USER and > $HTTP_AUTH_PW. When i change it to '$_SERVER['HTTP_AUTH_USER']' > and '$_SERVER['HTTP_AUTH_PW']' it does not work and i get a parse error. So the new assignment looks like this: $sql= "SELECT * FROM tbl_authenticate WHERE username = '$_SERVER['HTTP_AUTH_USER']' AND password = '$_SERVER['HTTP_AUTH_PW']'"; The problem is that PHP doesn't know what you are trying to do here. "'$_SERVER['HTTP_AUTH_PW']'" could mean "'(the value of $_SERVER)['HTTP_AUTH_PW']'" or what you intend. To get around that you need to enclose array elements (as well as other complex type structures like $myObject->property ) with braces (or place them outside the quoted value. The former: $sql= "SELECT * FROM tbl_authenticate WHERE username = '{$_SERVER['HTTP_AUTH_USER']}' AND password = '{$_SERVER['HTTP_AUTH_PW']}'"; and the later: $sql= "SELECT * FROM tbl_authenticate WHERE username = '".$_SERVER['HTTP_AUTH_USER']."' AND password = '".$_SERVER['HTTP_AUTH_PW']."'"; I prefer the later since it's a bit easier to read IMO. HTH Rod