You're looking at an archived, read-only version of our old community forum. See our new community forum here.

Need some PHP help

archard

Joined: Jan 11 2007

I know some people have offered to help me out with coding before, and now I really need some help.

The problem is, I have a global variable called $user which is an object that contains information about the currently logged in user (user name, user ID, session information, etc). I've instantiated that variable in several of my functions using "global $user;". But in one particular function the $user object seems to be destroyed. It always displays information about the admin user (user ID 1), no matter who is currently logged in.

What kind of things could cause a global variable to get killed like that? I've been looking through the code for days and I just don't know why it's doing this in that particular function, but behaving fine in others.

Re: Need some PHP help

yoshistrings

ヨッシー

Location: trapped in an egg

Joined: Oct 29 2007

...................................................................................................................................

sorry, I have no idea what that could possibly mean.

Re: Need some PHP help

Krimson

Much nerdy love

Joined: Jun 01 2008

If it's really destroyed in the particular function but works in others, I'd bet it's something in that particular function causing the problem...or a function that runs prior to that one. Either that or a typo...in which case you have my heartfelt condolences. :D Happy hunting!

Re: Need some PHP help

yoshistrings

ヨッシー

Location: trapped in an egg

Joined: Oct 29 2007

oh. A typo. I HATE looking for typos in pages and pages of code. the one time I had to do that, I got so frustrated that I I deleted every scrap of code and stated over

Re: Need some PHP help

Krimson

Much nerdy love

Joined: Jun 01 2008

I took a course on Python last semester. At least with C++ it'll point you to the missing semicolon that you inevitably forget...but with Python I would spend 5 minutes writing the program and an hour trying to find the one blasted colon or mispelling or indentation. At least it was pretty to look at...

Re: Need some PHP help

archard

Joined: Jan 11 2007

Yeah, I use this program called Zend which basically eliminates the possibility of a syntax error. I was able to figure it out though. $user was just being cached somewhere that I wasn't aware. How silly of me :geek:

----------

DANG