Menu

Use of undefined constant

CaPPsiE
2011-02-17
2012-09-07
  • CaPPsiE

    CaPPsiE - 2011-02-17

    Hi Guys,

    I've searched the support site but as yet have not really resolved this issue;
    the error I am seeing is:

    Use of undefined constant x_label - assumed 'x_label'

    Use of undefined constant y_label - assumed 'y_label'

    Use of undefined constant legend - assumed 'legend'

    I updated my XAMPP version to the latest which includes PHP 5.3.5 (the older
    version was php-5.2.9)

    Sadly the newer scripts do not work throwing up the aforementioned errors.

    Any thoughts?

    Ta.

     
  • lbayuk

    lbayuk - 2011-02-17

    That sounds bad, but I don't have enough info to tell where it is coming from.
    Let's check versions first. The current release of PHPlot is 5.3.1, and it was
    tested with PHP-5.3.5 (and 5.2.17). What version of PHPlot are you using? (The
    version can be found at the top of the phplot.php file.)

    Is there anything more to the error messages, such as a filename and line
    number?

    Those errors typically come from using an unquoted string as an array index,
    like $var. I don't see anything like that in PHPlot, however those three names
    (x_label, y_label, and legend) are used internally as indexes to an array that
    stores font information. So I would really like to know what is causing
    these errors.

     
  • CaPPsiE

    CaPPsiE - 2011-03-02

    Hiya,

    PHPLOT Version 5.3.1

    The apache log shows this line repeatedly:

    [Wed Mar 02 13:27:43 2011] [error] [client 172.16.255.21] PHP Notice:  Use of undefined constant x_label - assumed 'x_label' in /usr/proton/www/scr/278.upa.php on line 8, referer: [url]http://sohren001/proton/scr/278.menu.php[/url]
    
    [Wed Mar 02 13:27:44 2011] [error] [client 172.16.255.21] PHP Notice:  Use of undefined constant y_label - assumed 'y_label' in /usr/proton/www/scr/278.upa.php on line 9, referer: [url]http://sohren001/proton/scr/278.menu.php[/url]
    
    [Wed Mar 02 13:27:44 2011] [error] [client 172.16.255.21] PHP Notice:  Use of undefined constant legend - assumed 'legend' in /usr/proton/www/scr/278.upa.php on line 10, referer: [url]http://sohren001/proton/scr/278.menu.php[/url]
    
     
  • Matthew  Jones

    Matthew Jones - 2011-03-02

    Hello lbayuk

    I work with Cappsie, you are right it was caused by unquoted array indexes
    lables - from 270.hba.php

    $plot->SetFont(x_label,'', 8 );
    $plot->SetFont(y_label,'', 8 );
    $plot->SetFont(legend ,'', 10 );
    

    Putting in the quotes thus

    $plot->SetFont('x_label','', 8 );
    $plot->SetFont('y_label','', 8 );
    $plot->SetFont('legend' ,'', 10 );
    

    Made it work

    What is interesting is that the previous instalation of php/phplot although it
    reported an error to the error_log still plotted the graph. For what ever
    reson the up-to-date combination of php and phplot stalls on this error.

    New versions (Stalls on error) php 5.3.5 phplot 5.3.1

    Older versions (ignores error) php 5.2.9 phplot ?? - its probably the php
    change that caused it

    Thanks for your help

     
  • lbayuk

    lbayuk - 2011-03-02

    Hi folks, glad you got it fixed. You might want to check to see if your PHP
    configuration file (php.ini) changed between versions. In particular, the
    error_reporting level and the display_errors setting are key, I think. Just a
    guess, but perhaps your PHP 5.2 config did not display the warnings, and PHP
    5.3 did? If a warning is output by a script that is generating image data
    (like one that uses PHPlot), it will fail because the image data is corrupted
    by the message. I'm just guessing here, but I can't otherwise see why the
    behavior of unquoted array indexes would change between 5.2 and 5.3.

     
  • Matthew  Jones

    Matthew Jones - 2011-03-03

    Yes looks like that was the problem

    Old config

    error_reporting  =  E_ALL & ~E_NOTICE
    display_errors = On
    

    New Config

    error_reporting = E_ALL | E_STRICT
    display_errors = On
    

    That would acount for it. Thank you once again for your help

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.