How to fix “Headers already sent” error in PHP

No output before sending headers! Functions that send/modify HTTP headers must be invoked before any output is made. summary ⇊ Otherwise the call fails: Warning: Cannot modify header information – headers already sent (output started at script:line) Some functions modifying the HTTP header are: header / header_remove session_start / session_regenerate_id setcookie / setrawcookie Output can … Read more

Returning JSON from a PHP Script

While you’re usually fine without it, you can and should set the Content-Type header: <?php $data = /** whatever you’re serializing **/; header(‘Content-Type: application/json; charset=utf-8′); echo json_encode($data); If I’m not using a particular framework, I usually allow some request params to modify the output behavior. It can be useful, generally for quick troubleshooting, to not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)