-2

My website has a section where a user who has signed up for access (and has an existing profile) can edit their own profile. When the user clicks to save the profile changes, the following 4 PHP errors come up. My understanding is that often several errors appear due to the first one so I am hoping that resolving the first one is all it takes. Here I will provide details for number 1 only, rather than pasting so much code.

A PHP Error was encountered

Message: Use of undefined constant WEBMASTER - assumed 'WEBMASTER' Filename: controllers/content.php Line 285

Message: Cannot modify header info- headers already sent by (output started at ////system/core/Exceptions.php:185 Filename: libraries/Sessions.php Line 672

Message: Cannot modify header info- headers already sent by (output started at ////system/core/Exceptions.php:185 Filename: helpers/url_helper.php Line 542

Here is the code for 1. Line 285 begins with "$permission".

function edit($id="",$language=""){

    //which users are allowed to see this file.
    //* for everybody including those who are not registered
    //admin (or any other specific type for )
    $permission=array(ADMIN,WEBMASTER);
    $next_page=site_url("/content/manage");

Is there anything obviously wrong here?

Community
  • 1
  • 1
warren44
  • 15
  • 1
  • 1
    it seems that `ADMIN` and `WEBMASTER` constants are not defined inside the edit function? the headers sent error will go out if you fix this problem. – Lucho Oct 02 '15 at 14:34
  • You need to google for this. All these questions have been asked countless times before. – M H Oct 02 '15 at 14:35
  • if you didn't define those as constants, you need to use `$permission=array("ADMIN","WEBMASTER");` - Otherwise, define them http://php.net/manual/en/function.constant.php – Funk Forty Niner Oct 02 '15 at 14:36
  • @Lucho unless `ADMIN` and `WEBMASTER` are supposed to be strings (i.e. they should have quotes around them) ... – CD001 Oct 02 '15 at 14:36
  • If you're sending outputs before using `header`, you're going to have a bad time. – al'ein Oct 02 '15 at 14:39
  • I understand that this question may have been asked several times but none of the solutions were working for me. And yes I spent several hours google 'ing'. I finally resolved it minutes ago by deleting 2 redirects that were recently wriiten into the user.php file by my programmer who has apparently fallen off the edge of the planet. Thanks to all who provided feedback. – warren44 Oct 04 '15 at 00:36

3 Answers3

-2

You need to define the constant:

DEFINE('WEBMASTER', 'webmaster content here')

Regarding the 'headers already sent'.... this means you are trying to modify the headers when you have already sent output to the browser.

-2

First of all, you are not allowed to modify headers after data has been sent already.

So you should put everything what modifies the header before <!doctype html>. Just make sure there is nothing before the very first <?php, even not a single space.

Example:

<?php
    // do some header modification
?>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
....
</html>
xdevs23
  • 3,824
  • 3
  • 20
  • 33
-2

It means that there are some output in your php file before you make a redirection with function like header('Location: http://www.example.com/') ! you have to comment all "echo" "printf" or "html" before calling header function.

modiodio
  • 11
  • 2