-1

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

I have an pre-done php file thats help me read from an xml file. The problem is when im calling it from the html file ill get the undefined index.

I know Im missing something, but cant seem to know how to double? implement them in the get string.

xmlhttp.open("GET","prod.php?category=1"+str,true);
xmlhttp.send();

and the error message is pointing om row 7 in my PHP file where it says

$products = $_GET['products'];

If i change my GET file from category=1 to prodicts=1 i get the error in row 6 where the

$category = $_GET['category']; variable is.

Any ideas ?

thanks.

Community
  • 1
  • 1
Dymond
  • 2,158
  • 7
  • 45
  • 80

2 Answers2

2

You need to check if $_GET['products'] and $_GET['category'] even exist. Try:

if(isset($_GET['products'])){
    $products = $_GET['products'];
}
if(isset($_GET['category'])){
    $category = $_GET['category'];
}

It's saying that $products or $category are undefined.

SeanWM
  • 16,789
  • 7
  • 51
  • 83
  • This worked, when i changed the PHP file, but I'm not supposed to change that file. Is there another way i can manage the problem from the index file. – Dymond Jan 19 '13 at 15:30
0

You need to monitor the concrete HTTP request that you send to the server. If:

  • the query-part contains the variable, the error is wrong and you must have made something wrong in the PHP or webserver configuration.
  • the query-part does not contain those variables, the error messages are correct. You then might want to check why those variables are not part of the request.
hakre
  • 193,403
  • 52
  • 435
  • 836