-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,753
  • 72
  • 57
  • 129
Jeroen Bellemans
  • 2,049
  • 2
  • 25
  • 42

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,699
  • 7
  • 38
  • 49
Anand Solanki
  • 3,419
  • 4
  • 16
  • 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.