pesto Posted September 8, 2009 Share Posted September 8, 2009 part of my code: ----------------------------------------- var_dump($adr); echo "<BR>"; function print_form() { global $error, $print_again, $page, $vorn, $name, $adr, $abs, $betr, $mess, $empf; var_dump($adr); echo "<BR>"; ----------------------------------------- The first var_dump($adr) prints out a value (21 for example). The second var_dump($adr) has no more value, is prints out NULL. Can someone please tell me why? Link to comment https://forums.phpfreaks.com/topic/173511-variable-content-gets-lost/ Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 It's generally a bad idea to use global variables better would be to pass the variables as parameter to function. About your problem I cant see you calling that function anywhere`: print_form(); ? You just define the function but never call it or is there more code to this? <?php // define a function function sayHello() { echo 'heello!'; } // call the function sayHello(); // actually prints out that heello! Link to comment https://forums.phpfreaks.com/topic/173511-variable-content-gets-lost/#findComment-914604 Share on other sites More sharing options...
pesto Posted September 8, 2009 Author Share Posted September 8, 2009 /***** MAIN *****/ if(isset($submit)) { check_form(); } else { print_form(); } The script runs perfectly in PHP4, but no more in PHP5. Link to comment https://forums.phpfreaks.com/topic/173511-variable-content-gets-lost/#findComment-914614 Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 You probably had register globals on in your older installation of php. Since now you have to use $_POST['submit'] instead of $submit if your form is using POST method. $_GET global array wil have GET variables and $_REQUEST both POST and GET. Link to comment https://forums.phpfreaks.com/topic/173511-variable-content-gets-lost/#findComment-914618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.