PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, I'm a newbie, just trying to learn php. I'm getting some Notices that won't go away, I've looked at other posts here but haven't been able to figure it out myself.
I'm getting the following Notices in when I run my code.
Notice: Undefined index: search in C:\XXX\form_test.php on line 8
Notice: Undefined index: php_self in C:\XXX\form_test.php on line 9
array_name[array_index] is the format for a single, first dimension array member. When you reference an index in an array that index has to have been defined in that array or you will get the errors you are getting. Here is an example...
The above array now has two members that are referenced by indexes 'Honda' and 'Toyota'. If you attempt to call the array index 'Chrysler' what do you suppose will happen? Exactly. PHP will get mad at you for asking for something it does not have nor knows anything about.
And a quick note... don't use $_SERVER['PHP_SELF']. There are many posts around here as to why, but don't use it. Use something like basename(__FILE__) or something similar, but don't use PHP_SELF.
The notice you are getting means there is no 'search' index for the $_GET array. Are you passing ?search=something to your script? Also, you are checking for the array index called 'key' but you are trying to use the array index 'search'? Is that what you are intending to do?