Re: Quotes in querys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2009-01-14 at 15:24 -0500, Frank Stanovcak wrote:
> "Ashley Sheridan" <ash@xxxxxxxxxxxxxxxxxxxx> wrote in message 
> news:1231962521.3613.13.camel@xxxxxxxxxxxxxxxxxxxxxxxx
> > 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux