Warnings in using zenphoto

Hi,

I'm trying to use some of the zenphoto functions on my web site.
Unfortunately, I may have made some mistakes in my code.
I actually have the following errors :
Warning: Cannot modify header information - headers already sent by (output started at /.../accueil.php:2) in /.../galeries/zp-core/functions.php on line 1551

I include the zenphoto functions using this code :
if (!defined('WEBPATH')) define('WEBPATH', 'galeries/');
require_once(WEBPATH . "/zp-core/folder-definitions.php");
require_once(WEBPATH . ZENFOLDER . "/template-functions.php");

Thanks in advance for helping me.

Comments

  • Most likely you have placed these (or the functions) in the wrong place in your script. You must have these statements before our script creates any output [thus the gist of the error message.]

    The other source of this error is when you have a "blank" line in your script before (or after) the <?php....?> section.
  • Many thanks for your answer.
    I tried to place those lines at the beginning of my page :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">
    <?php
    if (!defined('WEBPATH')) define('WEBPATH', 'galeries/');
    require_once(WEBPATH . "/zp-core/folder-definitions.php");
    require_once(WEBPATH . ZENFOLDER . "/template-functions.php");
    $_page = "accueil";
    ?>

    Without any blank space before or after the <?php ... ?>
    And I still have the same warnings.
    Do you have any other idea ?
    Thanks for spending time with my issues.
  • acrylian Administrator, Developer
    If you are using another CMS for the rest of your site this might not work. It does for sure not with Wordpress for example and it is its "fault".
  • It's not a CMS.
    It's my personal website that I develop by my own.
    I may make a mistake somewhere.
    If you like to see :
    http://www.matthieurieux.com
  • acrylian Administrator, Developer
    Ok, I see but I can't dig into that. Seems you have some other code generating output before that.

    Don't know what you are planning but maybe doing the site entirely with Zenphoto and the Zenpage plugin would also be an option.
  • For a test, I tried to upload a web page with only this code :

    <?php
    if (!defined('WEBPATH')) define('WEBPATH', 'galeries/');
    require_once(WEBPATH . "/zp-core/folder-definitions.php");
    require_once(WEBPATH . ZENFOLDER . "/template-functions.php");
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
    </head>
    <body>
    </body>
    </html>

    And the warnings still appear.
    Nevertheless, I thought that was the way to call the zenphoto functions.
    Can you confirm ?
    Thanks for helping me
  • acrylian Administrator, Developer
    It is the so called "zenphoto as a 'plugin'" way. Try to leave out the folder definitions one and remove the slash after the WEBPATH define:
    http://www.zenphoto.org/2009/12/zenphoto-as-a-plug-in-using-zenphoto-functions-from-outside-zenphoto/

    However, this is nothing we really test frequently as Zenphoto is meant as a standalone script.
  • The warning will tell you where the output is happening. In the first case it was on your line #2, the doctype tag.

    What is the message for the second test? Maybe you still have a blank line or something prior to those lines of PHP code.
  • Thanks for your help.
    I've made again the test #2.
    And I have exactly the same error :
    Warning: Cannot modify header information - headers already sent by (output started at ... /accueil.php:2) in ... zp-core/functions.php on line 1551
    Furthermore, I don't have any extra blank line.
    Thanks again.
  • Well, you are outputting something at line 2 of your accueil.php script. Certainly we cannot tell what since we do not have that script to review. Presumably also the PHP code you inserted is after that line (since, among other things there are three lines to the code.)

    You need to fix accueil.php line 2.
  • Yes the error messages usually point you to the offending file or location. I'll definitely have a look again at accueil.php to work out what the problem is.
  • Here is my accueil.php file :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">
    <?php
    define('WEBPATH', 'galeries');
    require_once(WEBPATH . "/zp-core/template-functions.php");
    $_page = "accueil";
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
    <title>Matthieu Rieux - Accueil</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />
    <!--<meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />-->
    <link rel="stylesheet" type="text/css" media="screen, projection" href="/css/master_photos.css" />
    </head>

    <body class="photos">

    <!-- Le corps du site est en fait un tableau de 1 ligne 1 colonne , il est noir et encadré de gris sur un fond (body) un peu plus clair -->
    <table id="tab_corps">
    <tr><td>

    <!-- Le haut de la page -->
    <?php include($obj = "./hautpage/hautpage.php"); ?>

    <div id="contenu">
    <div class="albums">
    <p id="arbo">ACCUEIL</p>
    <?php if (getOption('Allow_search')) { printSearchForm(''); } ?>
    </div>
    </div>

    <!-- Le contenu de la page -->
    <?php include ('./galeries/themes/MatthRieux/moment.php'); ?>

    <!-- Le pied de page -->
    <?php include ('./piedpage/footer.php'); ?>

    </tr></td>
    </table>

    </body>
    </html>

    Again, many thanks for your help.

  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">

    This is output. Perhpas you need to review how PHP works.
  • Not sure to fully understand.
    So, I've tried without the first line.
    Without success.
  • acrylian Administrator, Developer
    You have probably an error somewhere, might be the require_once stuff for the Zenphoto functions that might not work. There would be an error in your server's error log about that somewhere. Since it does not happen on the pure Zenphoto part "Photos" it is most likely something with your php pages outside Zenphoto.

    Since you don't use another CMS you could do these pages as Zenphoto custom pages as well (or even using the Zenpage plugin) and then you would not need to include Zenphoto functions at all. See the theming tutorial maybe.

    Also Safari reports a file not found on "http://www.matthieurieux.com/img/banniere.jpg"
  • No, I don't.
    You're right.
    That's not my job actually.
    Thanks for your patience.

    On the server, there is an error.log file with (for example) :
    [19-Jul-2010 18:13:15] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/matthie1/public_html/materiel.php:2) in /home/matthie1/public_html/galeries/zp-core/functions.php on line 1551

    That's all the information I have.
  • You also have the responses of this thread. Which apparently you do not understand. I don't think I can be more explicit. The error message says that you have generated output at line 2 of your script. Line 2 is as quoted above. Having generated output at line 2 you cannot successfully call functions that do things like headers and cookies. So you have to fix line 2 as originally stated.

    I think from this conversation that your skills with PHP are probably not sufficient for you to be successful with this project. Certainly you cannot expect us to do your task for you. "that's not OUR job actually"
  • No problem.
    I don't expect you to do my tasks.
    Even if you have understood the contrary.
    I'm sorry for that (English is not my native language)
    Thanks for your help and your reactivity.
    I appreciate.
    I'll try to find out what are the php reasons that make the output at line 2.
    (I agree with you, I'm not familiar enough with php and html).

    Matthieu

    PS : the acrylian's post has been edited while creating mine, so responses to his questions don't make any sense now, that could explain our misunderstanding.
  • acrylian Administrator, Developer
    I had editied a little to show an easier altenative in using Zenphoto/Zenpage for everything on your site, in case that is possible.
Sign In or Register to comment.