lew14 Posted May 24, 2011 Share Posted May 24, 2011 I have several scripts that require register_globals. I do not use globals for security reasons. Is there a way to recode so the script will work without it? The code I am trying to change is: foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};} and function brotator($br_rid) { global $url,$dbhost,$dbuser,$dbpass,$dbname; $db = mysql_pconnect($dbhost, $dbuser, $dbpass) or die("Could not connect"); I have included the actaul file also. Thanks for any help you can give me. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
requinix Posted May 24, 2011 Share Posted May 24, 2011 The first bit of code imports global variables into a scope (such as function scope). That doesn't need any changing. For the second bit, the four $db variables are probably defined somewhere - not from form input. $url, on the other hand, might be from a form, in which case a simple $url = $_POST["url"]; // or $_GET["url"] at the beginning of the function would be enough. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.