1

I tried debug on my Wordpress. It is showing following error

Notice: Undefined index: category_one_middle in restaurant-menu-wordpress/plugin-main.php on line 273

<input id="category_one_middle" type="text" name="restaurantmenu_options[category_one_middle]" value="<?php echo stripslashes($settings['category_one_middle']); ?>" /><p class="description">Type category one name here.</p>

How do I fix this error? Any idea?

Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64
Rasel Ahmed
  • 305
  • 2
  • 8
  • 20

2 Answers2

2

You can use the function isset().

Try to replace the php code within value atribute with the following:

<?php echo isset($settings['category_one_middle']) ? stripslashes($settings['category_one_middle']) : ''; ?>

Also, keep in mind that any changes you make to the plugin files will be lost on its update.

More info about isset() function on PHP manual. A nice topic about Undefined index notices here.

Community
  • 1
  • 1
andreivictor
  • 7,628
  • 3
  • 48
  • 75
0

You need to take a look at the plugin-main.php file , I'd start at line 273 as that's what your error said. Somewhere you are having an undefined index.

For instance, if you'd echo $_POST['someindex'] , and there is no $_POST['someindex'], you'd get a undefined error.

someindex can be a counter too , commonly known as $i.