Jump to content

Why am I getting this error?


Go to solution Solved by Ch0cu3r,

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/296058-why-am-i-getting-this-error/
Share on other sites

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".

  • Solution

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.