SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is this syntax error?

    Hey,

    I have the following class:

    PHP Code:
    <?php

    class Gallery{
            
        public function 
    selectGalleryCategories(){

            
    $sql "SELECT * FROM tbl_gallerycategories";
            
    $result mysql_query($sql);
            return 
    $result;
        }
    }
    When i try using "include('classes/Galleries.class.php');" i get an error:

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/27/d208312252/htdocs/fusion/admin/classes/Galleries.class.php on line 5
    Line 5 is this:

    public function selectGalleryCategories(){
    Any idea what the problem is?

    Thanks
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what version of php? does it work without the public keyword?

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,687
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    The syntax error is due to PHP4 not understanding the public/private/protected visibility declarations.

    You'll need to either upgrade to using PHP5, or rewrite the code so that it doesn't use any PHP5 features in this case that means removing the public/private/protected visibility declarations.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    Thats exactly what the problem was, i added this line to my .htacces file:

    AddType x-mapp-php5 .php .php4
    And it now works

    Thanks
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •