/    Sign up×
Community /Pin to ProfileBookmark

Syntax question (kind of urgent)

Hi,

I have a table called “group” in my database.

I have some session data (if user 1 is signed in, group = 3)

Is this correct to assign $ group to the session group 3?

[code=php]
$group = $_SESSION[‘group’];
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 12.2011 — Not sure what you want, but the code you provided is assigning whatever value is in the session array "group" element to the variable $group (assignment takes the value on the right side of the "=" and copies/assigns it to the variable on the left side.) If you truly want "to assign $ group to the session group 3", then you need to swap the syntax to:
[code=php]
$_SESSION['group'] = $group;
[/code]
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...