0

Notice: Undefined index: n in C:\Users\Marseille\Desktop\Activation W7\UwAmp\www\quezzer\question.php on line 5

this is a code tiped at question.php

$number = (int) $_GET['n'];

why i have this error! i have not understand!

Pupil
  • 23,834
  • 6
  • 44
  • 66
  • Have you checked the variable exists? You shouldn't just assume that the variable will be set. Before doing anything with `$_GET['n']` ensure it exists with something like `if (isset($_GET['n'])) {}`. – Mikey Jan 25 '16 at 12:03
  • please do you speack french??, i am not english ;) – Hamid Marseille Jan 25 '16 at 12:14
  • Mon francais est assez mauvais, mais... (Google translate au sauvetage?) Avez-vous vérifié la variable existe ? Vous ne devriez pas simplement supposer que la variable sera établi . Avant de faire quelque chose avec `$_GET['n']` assurer qu'il existe quelque chose comme `if (isset($_GET['n'])) {}` . - – Mikey Jan 25 '16 at 12:26
  • no. the only problem here is the type of the $ number variable is int . I believe that the editor does not recognize the type – Hamid Marseille Jan 27 '16 at 10:02

1 Answers1

4

Since this is a get variable you're using, from what I understand is that you maybe trying to run the script questions.php directly. Therefore no get variables are set, try


localhost/yourfolder/questions.php?n=5

Aimal Azmi
  • 141
  • 7