View Full Version : Code won't work in functions

05-21-2004, 06:12 PM
I was trying to use my own function to repeat the same code over & over without using it all in the page again but have a problem..

Code works fine when not called via a function, but when I call the exact same code via the function, I have a problem..

The problem is that when I refer to a SESSION variable it doesn't work.

Any clue?


05-21-2004, 08:49 PM
maybe post the code of that function ...

05-21-2004, 09:07 PM
I find that sometimes I have to 'globalize' a variable declared outside of the function to use it inside.

$count = 0;
function inc_counter() {
global $count;

I don't know much about sessions as I've never used them before, but perhaps it's something similar?

Posting the relevant pieces of code would be helpful though..


05-21-2004, 10:11 PM
The code is really a bit to long to post (around 300 lines). I'll try & work with how I got it now. :D