debugging - Reference - What does this error mean in PHP? -
what this?
this number of answers warnings, errors , notices might encounter while programming php , have no clue how fix. community wiki, invited participate in adding , maintaining list.
why this?
questions "headers sent" or "calling member of non-object" pop on stack overflow. root cause of questions same. answers questions typically repeat them , show op line change in his/her particular case. these answers not add value site because apply op's particular code. other users having same error can not read solution out of because localized. sad, because once understood root cause, fixing error trivial. hence, list tries explain solution in general way apply.
what should here?
if question has been marked duplicate of this, please find error message below , apply fix code. answers contain further links investigate in case shouldn't clear general answer alone.
if want contribute, please add "favorite" error message, warning or notice, 1 per answer, short description means (even if highlighting terms manual page), possible solution or debugging approach , listing of existing q&a of value. also, feel free improve existing answers.
the list
- nothing seen. page empty , white. (also known white page/screen of death)
- code doesn't run/what looks parts of php code output
- warning: cannot modify header information - headers sent
- warning: mysql_fetch_array() expects parameter 1 resource, boolean given a.k.a.
warning: mysql_fetch_array(): supplied argument not valid mysql result resource a.k.a.
warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given (or similar variations) - warning: [function] expects parameter 1 resource, boolean given
- warning: [function]: failed open stream: [reason]
- warning: open_basedir restriction in effect
- warning: division zero
- warning: illegal string offset 'xxx'
- parse error: syntax error, unexpected '['
- parse error: syntax error, unexpected t_xxx
- parse error: syntax error, unexpected t_encapsed_and_whitespace
- parse error: syntax error, unexpected t_paamayim_nekudotayim
- parse error: syntax error, unexpected t_variable
- fatal error: allowed memory size of xxx bytes exhausted (tried allocate xxx bytes)
- fatal error: call member function ... on non-object
- fatal error: call undefined function xxx
- fatal error: cannot redeclare xxx
- fatal error: can't use function return value in write context
- fatal error: declaration of aaa::bbb() must compatible of ccc::bbb() '
- fatal error: using $this when not in object context
- notice: array string conversion
- notice: trying property of non-object error
- notice: undefined variable
- notice: undefined index
- notice: undefined offset xxx [reference]
- notice: uninitialized string offset: xxx
- notice: use of undefined constant xxx - assumed 'xxx'
- mysql: have error in sql syntax; check manual corresponds mysql server version right syntax use near ... @ line ...
- strict standards: non-static method [<class>::<method>] should not called statically
also see
warning: cannot modify header information - headers sent
happens when script tries send http header client there output before, resulted in headers sent client.
this e_warning
, not stop script.
a typical example template file this:
<html> <?php session_start(); ?> <head><title>my page</title> </html> ...
the session_start()
function try send headers session cookie client. php sent headers when wrote <html>
element output stream. you'd have move session_start()
top.
you can solve going through lines before code triggering warning , check outputs. move header sending code before code.
an overlooked output new lines after php's closing ?>
. considered standard practice omit ?>
when last thing in file. likewise, common cause warning when opening <?php
has empty space, line, or invisible character before it, causing webserver send headers , whitespace/newline when php starts parsing won't able submit header.
if file has more 1 <?php ... ?>
code block in it, should not have spaces in between them. (note: might have multiple blocks if had code automatically constructed)
also make sure don't have byte order marks in code, example when encoding of script utf-8 bom.
related questions:
Comments
Post a Comment