upgrading script from using GLOBALS

From: Date: Wed, 02 Oct 2002 17:59:05 +0000
Subject: upgrading script from using GLOBALS
Groups: php.general 
Request: Send a blank email to php-general+get-118624@lists.php.net to get a copy of this message
Hi, I am trying to upgrade my script which currently uses globals (and register_globals=on) to turning that flag off. The online documentation on register globas has the following code recommended by users in order to register the variables: $GLOBALS["dbname"] = "dbname"; //register globals foreach ($GLOBALS as $key=>$val) { if ($key !="GLOBALS') {
     eval("\$$key = '$val';");
} } I am using the global array to connect to my database. I find that if I insert the code above, I get an error message that the document contains no data. Can anyone tell me why? Perhaps I would be better off just declaring the variable? Would that take care of the problem? $dbname= "dbname"; Thanks, Nicole -- ######################## Nicole Lallande nicole@nmlconsulting.com 760.753.6766 ########################

« previous php.general (#118624) next »