using database to set global variables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jschoneb
Forum Newbie
Posts: 17
Joined: Thu Aug 22, 2002 11:51 am
Location: New York City

using database to set global variables

Post by jschoneb »

This may be impossible, but if it's not, it would really improve my life if somebody could clue me in.

Situation: I have a single PHP script with functions to display forms for updating various MySQL database tables, and a function to send the relevant commands to the database and insert the data. The "insert" function has to have all the variables from the other functions declared global -- as opposed to if the insert task was in a completely separate script, in which case it would just automatically welcome the little variables with open arms.

If my variables change, however, then I need to remember to fix the globals in the insert function. What a pain! I want to do it automatically, generating the globals from the database itself.

I know how to get the field names from the database, and how to turn them into variable names, so I tried doing that and making a string out of them and writing:

Code: Select all

global $variables_from_database_string;
But that doesn't work.

Is it possible? Any ideas out there?

thanks!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

read http://www.php.net/manual/en/language.v ... riable.php and then try something like
global $$variable_from_database_string;
Post Reply