getting warning “Header may not contain more than a single header, new line detected”

后端 未结 7 891
遇见更好的自我
遇见更好的自我 2020-12-07 01:07

I am doing coding in oops for uploading image in PHP. But After submit image, it\'s giving warning

\"Header may not contain more than a single header, new line detec

相关标签:
7条回答
  • 2020-12-07 01:25

    Trouble could be in your phpMyAdmin, table wp_options, option_value.

    If there is a space before the URL it will generate the ERROR: warning: header may not contain more than a single header, new line detected in...

    0 讨论(0)
  • 2020-12-07 01:33

    You shouldn't put more than two lines in URL address. Check you URL.

    Good URL - "http://mail.google.com"  - 1 line
    
    Bad URL - "http://mail.              - 2 lines
                google.com/"
    
    0 讨论(0)
  • 2020-12-07 01:34

    This warning occurs to indicate that you might have a new line [/n] in the string content of your variables. Example

      header("Location: ../control.php?post='$title1'&sample='$val'");
    

    here there are 2 variables

    $title1 and & $val

    so while running if This warning occurs warning

    “Header may not contain more than a single header, new line detected”

    The solution is To strip out the passable new line contents of the variable Like this

        $val=str_replace(PHP_EOL, '', $val);
        $title1=str_replace(PHP_EOL, '', $title1);
    

    Then you can include the variables in the header


    The ideal way of solving it is like this

    $url="../control.php?post='$title1'&sample='$val'";
     $url=str_replace(PHP_EOL, '', $url);
     header("Location: $url");
    

    ** This will work 100%;**

    0 讨论(0)
  • 2020-12-07 01:37

    Try encoding your URL and it should work : http://php.net/manual/en/function.urlencode.php

    0 讨论(0)
  • 2020-12-07 01:37

    in "Illuminate\Auth\Middleware\Authenticate" The method "redirectTo" should return an url path, not the Redirect response.

    ...
    protected function redirectTo()
    {
        if(\Auth::user()->hasRole('copy')){
            return '/copy/dashboardCopy';
        }       
    }
    ...
    
    0 讨论(0)
  • 2020-12-07 01:39

    Seems like the variables you are using to create the Location attribute has a new line character in them. Pass them through urlencode()

    0 讨论(0)
提交回复
热议问题