-1

How do you define a variable which holds the $_GET['value']; ?

I get this error UNDEFINED INDEX: cat IN C... ON LINE 20 while doing this:

$cat = $_GET['cat'];
$cat_array = array('users', 'projects', 'roles', 'library', 'bugs');

How can I define the $cat

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Jeroen Bellemans
  • 2,021
  • 2
  • 22
  • 40

2 Answers2

1

Check variable has that index & value first then assign.

isset($_GET['cat']){
      $cat = $_GET['cat'];
}

Always check array index before use it.

You can read more about isset in the PHP documentation.

Let me know for more help.

alexwlchan
  • 5,074
  • 5
  • 34
  • 44
Anand Solanki
  • 3,370
  • 4
  • 15
  • 27
0

I didn't understand what you are asking... You said how to define a variable to hold a value from GET Array. Well, there only one way to define a variable, which is by starting variabke name with $ sign....

Error is Undefined Index:: you might have not written 'cat' named field into the form. Go and check it first.