Re: HTTP_AUTH and SQL WHERE Clause - Mailing list pgsql-php

From Rod Taylor
Subject Re: HTTP_AUTH and SQL WHERE Clause
Date
Msg-id 1064759185.21931.32.camel@jester
Whole thread Raw
In response to Re: HTTP_AUTH and SQL WHERE Clause  ("Rod K" <rod@23net.net>)
List pgsql-php
> 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.

Another alternative:

$sql = <<<END
SELECT *
  FROM tbl_authenticate
 WHERE username = '%s'
   AND password = '%s';
END

$psql = sprintf($sql, pg_escape_string($_SERVER['HTTP_AUTH_USER']),
        pg_escape_string($_SERVER['HTTP_AUTH_PW']));


Attachment

pgsql-php by date:

Previous
From: "Rod K"
Date:
Subject: Re: HTTP_AUTH and SQL WHERE Clause
Next
From: "Sebastien Baudry"
Date:
Subject: How to call a PL/pgSQL function in a PHP script?