Undefined index php help

Asked

Viewed 78 times

-4

Good people I’m doing a php test and gave me an error that I’m not able to solve this is the test: teste

and here’s my job the error and on line 22inserir a descrição da imagem aqui

  • 1

    you started the session within the function but did not make her call, so $_SESSION['x'] there is no.

  • Use a condition if..else or ternary to check if the value exists before printing it. Ex.: echo isset($_SESSION['x']) ? $_SESSION['x'] : 'No ecxiste';

  • 1

    Include code instead of images

1 answer

0

I believe this problem is happening because there is no Session with value 'x' defined. By its code, Session is defined in a javascript function that is never called :/. That is if you try to use Session 'x' and it does not exist it will probably give Undefined index error. And this you can deal with an if before displaying, for example:

isset($_SESSION['x']) ? $_SESSION['a'] : null;

Try calling the function "numerox();" or by an onclick/onchange event or put this piece after the end of the function, just to see if it works, if it doesn’t work, post the code to help you better.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.