0

No error in log of Apache... This is my function:

function feedback($type,$message,$link=NULL) {
    if ( (isset($_POST['ajaxFeedback'])) && ($_POST['ajaxFeedback']==true) ) {
        echo '<div class="alert alert-'.$type.'">';
            echo '<p>'.$message.'</p>';
        echo '</div>';
        exit;
    } else {
        $_SESSION['typeMessage']    = $type;
        $_SESSION['message']        = $message;
        if (isset($link)) {
            header('Location: '.LINK_ASSOLUTO.$link);
        }
        exit;
    }
}

if i call it with

feedback('success','All queries OK',$link=NULL);

i obtain stop of execution of page (all rest of page will be blank). Also if I omit $link and if I pass $link without the "=NULL".

If I pass a link, e.g.

feedback('success','All queries OK','/index.php');

all works (i've used this function in several codes).

Help me.. thank you!

3
  • 2
    Why would you want to do feedback('success','All queries OK',$link=NULL); if it defaults to that? Do feedback('success','All queries OK'); instead. Commented Oct 18, 2013 at 18:09
  • 1
    Your code paths are confusing you. Your if() test does not consider ANYTHING of what you pass in as arguments. the if() results depend entirely on $_POST values. Note that isset($null) is FALSE, so your header() call never occurs if you don't pass in a $link, or explicitly pass in a null - your script will set two sessionv values and then simply exit. Commented Oct 18, 2013 at 18:10
  • @MarcB you did put me in right way. In effect that "exit" must be to stay in if (isset($link) piece of code... Thank you very much :) Commented Oct 18, 2013 at 18:23

1 Answer 1

3

You can't set a default in the call of a function only the declaration. You should either call:

feedback('success','All queries OK');

or

feedback('success','All queries OK',null);

Also if $link is null and $_POST['ajaxFeedback'] is not set your code just sets session values. However I don't see where you are using session_start()

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

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.