Re: Quotes in querys
| From: | Frank Stanovcak | Date: | Wed, 14 Jan 2009 20:24:21 +0000 |
| Subject: | Re: Quotes in querys | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286349@lists.php.net to get a copy of this message | ||
"Ashley Sheridan" <ash@ashleysheridan.co.uk> wrote in message
news:1231962521.3613.13.camel@localhost.localdomain...
> On Wed, 2009-01-14 at 11:17 -0500, MikeP wrote:
>> Hello,
>> I am trying to get the following to work:
>> "Select Netid from Users where Netid = '$_SESSION[phpCAS][user]'"
>> Netid is a string type.
>> No matter where of if I put the quotes, I still get array[phpCAS] not the
>> value.
>> If there is anything I still have trouble with after all these years its
>> quoting variables.
>> Help?
>> Thanks
>> Mike
>>
>>
>>
> I always go with this:
>
> "Select Netid from Users where Netid = '{$_SESSION[phpCAS][user]}'"
>
> The curly braces allow PHP to use the full variable you intended. Note
> that you may need single quote marks around the text in each square
> bracket block or PHP my give you a warning about an unintended string
> literal.
>
>
> Ash
> www.ashleysheridan.co.uk
>
even though it might have it's drawbacks I've never had a problem with
concat for sql statements.
$sqlstmt = "Select Netid from Users where Netid = '" .
$_SESSION['phpCAS']['user']} . "'";
Frank