Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17275

Re: Problem validating user and hashed value in db

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.php
Subject Re: Problem validating user and hashed value in db
Date 2017-01-13 16:27 +0100
Organization PointedEars Software (PES)
Message-ID <2705791.CbtlEUcBR6@PointedEars.de> (permalink)
References (8 earlier) <1637589.atdPhlSkOF@PointedEars.de> <40785270-a157-4582-a129-e5afb0f94714@googlegroups.com> <o58ahb$5t4$1@solani.org> <46bf833a-2b4c-4258-a9bf-b7f7d0ab224a@googlegroups.com> <o58ib6$bu4$1@solani.org>

Show all headers | View raw


Christoph M. Becker wrote:

> On 12.01.2017 at 19:18, wart2ww wrote:
>> I did check [the error log] and got the following error message: PHP
>> Warning:  Cannot modify header information - headers already sent by
>> (output started at......
>> 
>> The sites main menu contains an option to open the same page as the php
>> codes header('location'....
>> 
>> Can that be the problem?
> 
> If an header is supposed to be sent, but isn't, that certainly could
> cause all kinds of issues.  Instead of wondering whether this very issue
> is caused by the failing header call, I suggest you fix it, and then
> check whether the other issue still persists. :-)

Regarding the fix: the problem may not be obvious, neither may be the fix.

As the warning says, the header() call fails because output has already been 
sent (and so implicitly at least the default “Content-Type: text/html” 
header _field_ – it’s the *P*HP *H*ypertext *P*reprocessor).  For example,

  <?php

  echo 42;
  header('Content-Type: text/plain', true);

will echo “42” but not send the specified Content-Type header _field_.  

Likewise,

  <?php

  echo 42;
  header('Location: …', false, 302);

will not cause redirection.  This has to do with the structure of an 
Internet message (see RFC 5322) that an HTTP response is (see RFC 7230);
the one caused by the premature “echo” statement above is at least

-----------8<----------
Content-Type: text/html

42
-----------8<----------

There is no way that more header fields can be sent at this point, because 
it is an output *stream*, and we have already output a part of the message 
body.

A common reason for this warning is when one does not follow the 
recommendation in the PHP-FIG PSR-2 Coding Style Guide to not write the “?>” 
at the end of files that contain only PHP code (I would extend that 
recommendation to files that *end with* PHP code). [1]  Because then any 
whitespace that follows *is* output, too.  If, for example, you have 
configured your editor to add a newline when saving the file (or it does 
that without asking), you will cause PHP to generate output; not so if you 
omit the “?>”.

Another common reason are error messages or warnings being output before 
header(), but we might be able to exclude that here as error messages are 
going into the error log.

[1] <http://www.php-fig.org/psr/psr-2/#files>

-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-10 12:46 -0800
  Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-10 22:39 -0500
    Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-10 19:51 -0800
      Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-10 23:28 -0500
        Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-10 22:32 -0800
          Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-11 12:47 +0100
            Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-11 09:07 -0500
              Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-11 15:37 +0100
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-11 15:40 -0500
                Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-11 23:18 +0100
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 07:32 -0800
                Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-12 17:23 +0100
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 10:18 -0800
                Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-12 19:36 +0100
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 11:12 -0800
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 12:05 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-12 15:20 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 13:51 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-12 17:00 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 13:53 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-12 17:02 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 07:16 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 10:39 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 09:06 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 12:58 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 10:30 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 13:57 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 13:29 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 16:57 -0500
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 14:23 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-14 13:03 -0500
                Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-13 20:02 +0100
                Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-13 21:35 +0100
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 16:24 -0500
                Re: Problem validating user and hashed value in db Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-14 02:37 +0000
                Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 19:20 -0800
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-14 12:57 -0500
                Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-14 19:47 +0100
                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-14 14:00 -0500
                Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-13 16:27 +0100
                Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-13 16:39 +0100
          Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-11 09:22 -0500

csiph-web