Page 1 of 1

storing variables

Posted: Wed Jun 01, 2005 2:46 pm
by jaymoore_299
What is the best way to store variables (that don't store any important data) in a file then access and modify them easily from any php script?

I was thinking of a file with a list of variables like this:

$var1='1';
$var2='2';
$var3='3';
..
..
$var7='7';

What if I had a program that only needs 2 variables, and with the need to change them right after using them?

Posted: Wed Jun 01, 2005 2:54 pm
by timvw
i would store them in:
- a database... (application wide)
- a session... (user wide)

Posted: Wed Jun 01, 2005 3:49 pm
by pickle
Don't store them in a flat file - too much overhead, security issues etc, use a database or a session like ~timvw suggested.

What are you going to use these variables for? Are they going to be:
  • valid and unique for a single users visit or,
  • 1 set of variables for all users or,
  • variables that apply to a user over multiple visits?
If the situation is the first I mentioned, I'd use sessions. If the situation is the 2nd, I'd use a database. If the situation is the 3rd, I'd use a database as well, although cookies might be able to work as well.

Posted: Wed Jun 01, 2005 4:52 pm
by jaymoore_299
the variables are for internal use only. I need variables to keep track of things like, hit tracking, rotation of links, etc.

If I have 100 links and rotate 3 a day, I need a variable to store where I left off last so that all the links are evenly cycled through.

Posted: Wed Jun 01, 2005 5:02 pm
by Spaceboy
A database would be the easiest thing. Do you MySQL?