First off I'm getting this error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/eleme6/public_html/scgi-bin/text_to_image_inc.php on line 19

Line 19 is: private $text_color = 'black'; just after class statement. Help!

<?php

/**
* This class converts any string into a image (gif / jpg/ png) on the fly.
*
* @author  Rochak Chauhan
*
* @version 2: Added new features to display and/or save created image.
*                
* Dependency - GD Library Needed */ require_once("websafecolors_inc.php"); class ConvertTextToImage extends WebSafeColors { private $text_color = 'black'; private $image; private $width; private $height; /** * Function to Initialise the image * * @param $width int - required width of the image * @param $height int - required height of the image * @param $bgColor string - Color (in hexadecimal / RGB / Color Name) * @param $textColor string - Color (in hexadecimal / RGB / Color Name) * */ public function initializeImage($width, $height, $bgColor, $textColor) { if($width <= 0 || $height <= 0 || !is_numeric($width) || !is_numeric($height) ) {

2nd

I been looking for some place to help me understand that error message. To me it says ' something broke on line 19'

after a long search I did find an explanation that only a compiler could understand. Is there a place the breaks the error messages down to simpler terms?

thanks kc

    Are you sure PHP5 is enabled?

    Can you post more of the code?

      I guess there is some clue that php 5 is needed that I missed. No my server is php 4.3.

        Is it possible there's some non-printing character between the "private" and the "$text_color"? I as this because (1) the spacing is different on that line than the other lines, and (2) when I copied and pasted your code and trimmed it down to just those lines (see below) it ran just fine:

        <?php
        
        /**
        * This class converts any string into a image (gif / jpg/ png) on the fly.
        *
        * @author  Rochak Chauhan
        *
        * @version 2: Added new features to display and/or save created image.
        *                
        * Dependency - GD Library Needed */ class ConvertTextToImage { private $text_color = 'black'; private $image; private $width; private $height; } ?>
          kansaschuck wrote:

          I guess there is some clue that php 5 is needed that I missed. No my server is php 4.3.

          Yeah, the "private" declarations require the PHP 5 object-oriented features. You could try changing "private" to "var" and see if you get lucky.

            PS: For a little help in analyzing those error messages, this appendix contains a description of all those "T_SOMETHING" parser tokens. The error message you got simply was telling you it encountered a variable (T_VARIABLE) where it wasn't expecting to see one. Unfortunately, they seldom tell you why they weren't expecting it. 🙂

              NogDog wrote:

              Unfortunately, they seldom tell you why they weren't expecting it.

              Well, they do tell you what was expected. I suspect it would be difficult to be more informative in the general case.

                Write a Reply...