>I want to add a set of values to the session variable $BOOKS. This is the
>code which I used.
>
> if($BOOKS=="")
> {
> #this seems to be the first book which the user has selected
> $BOOKS = $bookid; #this param comes from the URL
> }
> else
> {
> $BOOKS = $BOOKS+","+$bookid;
> }
>
>Here the 'if..' part gets executed, and because of that I cannot add details
>of another book. I have initialised the session and added the registered the
>value "BOOKS" in the previous page.
Did you call session_start() in this page?
Cuz if not, like, PHP doesn't know you want to use the session variables
from the other page.
Also, it's not + to concatenate strings in PHP. It's .
$BOOKS = $BOOKS . "," . $bookid;
And, what's more, you can shorten $foo = $foo . xxxxxxxxxxxxxxxxxxx to:
$foo .= xxxxxxxxxxxxxxxxxxxxxx
So, in your case, it's:
$BOOKS .= "," . $bookid;
And, since you can "bury" variable in strings and work, even go with:
$BOOKS .= ",$bookid";
You might, however, want to turn $BOOKS into an array anyway:
$BOOKS[] = $bookid;
But you'll need to read up on arrays to use them.
--
Like Music? http://l-i-e.com/artists.htm
Off-Topic: What is the moral equivalent of 'cat' in Windows?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php