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] Link to comment https://forums.phpfreaks.com/topic/237300-help-with-register_globals/ 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. Link to comment https://forums.phpfreaks.com/topic/237300-help-with-register_globals/#findComment-1219434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.