|
Posted by Norman Peelman on 06/20/05 02:54
"Tony" <tony23.no@dslextreme.com.spam> wrote in message
news:11b47il500ieq16@corp.supernews.com...
> toedipper wrote:
> > Hello,
> >
> > Is this the right syntax for assigning a sql selct to a variable. When I
> > use this I get a parse error on the line that this is on.
> >
> > $thecustid = 'SELECT custid FROM customers WHERE userid =
> > $_SESSION['MM_Username']';
>
> No.
>
> You have a few problems. First of all, you are using single-quotes inside
a
> single-quoted string. Second, you can't include an array variable inside a
> string like that you'll have to use concatenation. Third, you aren't
> quoting the string content in the query - I expect this will likely cause
> problems on the SQL side.
>
> Try
> $thecustid = "SELECT custid FROM customers WHERE userid='" .
> $_SESSION['MM_Username'] . "'";
>
This also will work (previous example can get you lost in quotes and is hard
to read with uneccessary string concatination) :
$thecustid = "SELECT custid FROM customers WHERE userid=
$_SESSION[MM_Username]";
....when using array variables inside ".." you omit the '..' around the key
name.
Norm
--
FREE Avatar hosting at www.easyavatar.com
Navigation:
[Reply to this message]
|