0

I am getting a Notice in a wordpress theme, but i think its a general PHP warning.

Notice: Undefined index: saved in ..\functions.php on line 255

The line 255 reads as:

if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';

Any suggestion, how i can fix it?

Thanks.

4 Answers 4

5

Change to:

if(isset($_REQUEST['saved']))

You should consider using a method specific super-array like $_GET or $_POST instead of the more general $_REQUEST array.

Sign up to request clarification or add additional context in comments.

Comments

2
if ( isset($_REQUEST['saved']) && $_REQUEST['saved'] ) ...

Comments

1

Yes, this is a general php notice. You should use "empty" function like this:

<?php

if (!empty($_REQUEST['saved']))
    echo '<div id="message" class="updated fade"><p><strong>'
    . $themename
    . ' settings saved.</strong></p></div>';

This function will save you from "false", "0" and other "empty" values.

Comments

0

You can also check if a variable is set using isset(). Not sure if this applies to your specific situation.

if ( isset($_REQUEST['saved']) ) {
     echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.