ramzess Posted September 20, 2006 Share Posted September 20, 2006 Hi guys!I just found out that my code for changing contents of a table cell is not working on some servers.Later I found out why - it is because 'register_globals' in php.ini is Off. On ones I tried this simple scriptit was On.This is my simple code. Sure now way to make it even more simple. But What can I do about it?How can I define this variable $cng? If I define it a value script stops working. :(I can't believe - it should be so common to use this one, please, is there really no way out?[code]<?php switch ($cng) { case "1"; require ('content/page1.php'); break; case "2"; require ('content/page2.php'); break; default; require ('content/page0.php');}?>[/code]Of course, links for calling in those pages is like:<a href="?cng=1">Page 1</a> and <a href="?cng=2">Page 2</a>Is there a solution? Thank you. Link to comment https://forums.phpfreaks.com/topic/21368-switch-is-not-working-because-of-register_globals-off/ Share on other sites More sharing options...
Barand Posted September 20, 2006 Share Posted September 20, 2006 Get the value of the variable from the querystring[code]$cng = $_GET['cng'];switch ($cng) {[/code]When coding, always assume the register_globals setting is OFF Link to comment https://forums.phpfreaks.com/topic/21368-switch-is-not-working-because-of-register_globals-off/#findComment-95135 Share on other sites More sharing options...
ramzess Posted September 20, 2006 Author Share Posted September 20, 2006 Thank you Barand. Thank you.Oh yes, from now on I will work with register_globals Off to escape such situationswhen you suddenly find something is not working somewhere.Thank you. Link to comment https://forums.phpfreaks.com/topic/21368-switch-is-not-working-because-of-register_globals-off/#findComment-95138 Share on other sites More sharing options...
Barand Posted September 20, 2006 Share Posted September 20, 2006 This should helphttp://www.php.net/manual/en/language.variables.external.php Link to comment https://forums.phpfreaks.com/topic/21368-switch-is-not-working-because-of-register_globals-off/#findComment-95141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.