Re: Quotes in querys
| From: | Ashley Sheridan | Date: | Wed, 14 Jan 2009 20:32:54 +0000 |
| Subject: | Re: Quotes in querys | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286351@lists.php.net to get a copy of this message | ||
On Wed, 2009-01-14 at 15:24 -0500, Frank Stanovcak wrote:
> "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
>
>
>
That wont work, you forgot to take out the extra } at the end ;)
Ash
www.ashleysheridan.co.uk