cloudll Posted May 4, 2015 Share Posted May 4, 2015 Hey everyone, I have just transfered to a new server and an getting a few error messages now. I am getting this one: PHP Notice: Undefined index: movement in on line 113. Which is this line of code: $movement = $_REQUEST['movement']; This worked fine on my old server but I'm guessing maybe this one has stricter error reporting maybe. Is it due to the fact that unless I make the url request, $movement is empty ? Sorry still a novice at PHP. Quote Link to comment Share on other sites More sharing options...
fastsol Posted May 4, 2015 Share Posted May 4, 2015 Your assumption is most likely correct, but it's impossible for us to say for sure with a single line of code. Typically vars like POST, GET and REQUEST are wrapped in an if() block or checked with isset() before setting their value to another var. The error is just saying that there is no global / superglobal set with the name of "movement". Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted May 4, 2015 Solution Share Posted May 4, 2015 You are getting that notice because the index 'movement' does not exist within $_REQUEST array. On all input variables you should check they exist before using them. A few examples $movement = ''; if(isset($_REQUEST['movement'])) $movement = $_REQUEST['movement']; // or using ternary operator $movement = isset($_REQUEST['movement']) ? $_REQUEST['movement'] : ''; This worked fine on my old server but I'm guessing maybe this one has stricter error reporting maybe. On your old server either error reporting was set to ignore notices or it was configured so errors would not be displayed. Quote Link to comment Share on other sites More sharing options...
cloudll Posted May 4, 2015 Author Share Posted May 4, 2015 Thats great, thank you. 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.