Page 1 of 1

Getting strange parse error

Posted: Wed Sep 11, 2002 9:46 am
by ebertjb
I am getting the following error:

Parse error: parse error, unexpected $ in /var/home/hsgroups/htdocs/include/Page.inc.php on line 279

Fatal error: Cannot instantiate non-existent class: page in /var/home/hsgroups/htdocs/include/Page.inc.php on line 10

Interesting things about this -
1) On my local environment (IIS 5 and Win2k) it works fine, whereas dev environment (apache on unix) it doesnt

2) Line 279 is the eof and 10 is the line inside function GetPage that instatiates an object of type Page.

3) the structure of the include is as such
Function GetPage()
Class Page
Class Template

But if I change the structure to be this
Class Page
Class Template
Function GetPage()

then I get the following errors:
Parse error: parse error, unexpected $ in /var/home/hsgroups/htdocs/include/Page.inc.php on line 280

Fatal error: Call to undefined function: getpage() in /var/home/hsgroups/htdocs/personal_growth/PersonalGrowth.php on line 19

--> Its as if in the first structure, getpage cannot find class page, and in the second structure, the calling php page cant find function getpage.

any ideas????

Posted: Thu Sep 12, 2002 4:34 am
by volka
how do you include (you do, don't you?) the file where the class is definied? Maybe this fails on your unix-system. Check apache's error-log.

Tried a couple things

Posted: Thu Sep 12, 2002 7:57 am
by ebertjb
It was originally this

Code: Select all

include_once("../include/Page.inc.php");
But I have also tried these:

Code: Select all

include_once("include/Page.inc.php");
include_once("\include\Page.inc.php"); 
include_once(".:/include/Page.inc.php"); 
include_once("./include/Page.inc.php");
And lastly I just put my file in the same folder as the include and did this, but it still didnt work:

Code: Select all

include_once("Page.inc.php");
What is the normal unix-based path to do this???

Posted: Thu Sep 12, 2002 8:37 am
by jason
It would help to actually see the file the error is on.

Rediculous error - Found Solution

Posted: Thu Sep 12, 2002 9:05 am
by ebertjb
Ok - this is pretty rediculous.... dont know what Unix/Apache has a problem with on this... I started rem'ing out my code in my include file, and found the culprit - it was a REM statement that was setting a string variable, but had a variable ($year) in the middle of the statement.

Once I deleted this rem statement, everything worked fine.

Posted: Thu Sep 12, 2002 9:08 am
by jason
Probably because PHP doesn't have REM. I would still like to see the file, that way I can tell you what the problem was, rather than you guess.

ok - here is the file

Posted: Thu Sep 12, 2002 10:07 am
by ebertjb
Ok - here is the code of the include - the line with the /*****/ is what was causing it to blow up. Removing it fixed it - dont really know why though.

Code: Select all

<?php

//Page.inc;

//include_once("../include/DBclass.inc.php");

Function GetPage($sPageName)
&#123;
$pPage = New Page($sPageName);
Return $pPage;
&#125;

Class Page
&#123;
        /* Public Variables */
        Var $Name;
        Var $Visible;
        Var $IsPublic;
        Var $URL;

        /* Private Variables */
        Var $HeaderHTML;
        Var $HeaderBeginHTML;
        Var $HeaderEndHTML;
        Var $HeaderAdditional;
        Var $FooterHTML;
        Var $TitleHTML;
        Var $PageTitle;
        Var $Template;

        Function Page($npage)
        &#123;
         //Verify that this is a valid page in the page table;
         /* $rsPage = GetRecordset("page");
         $rsPage->Select("WHERE Name = '$Page'");
         $recPage =& $rsPage->GetRecordAtRow(1);
         $fldPage =& $recPage->GetField("ID");
         If ($fldPage->Value <> 0)
                $valid = true;
         else
                $valid = false;
         */
         //echo "<br> Valid: " .$valid;
         //echo "<br> Value: " .$fldPage->Value;

         //Verify that this is a valid page in the wwwroot directory;

         $valid = true;
         $year = date("Y");
         if ($valid == true)
         &#123;

                 $this->Name = $npage;
                 $this->Visible = True;
                 $this->PageTitle = "";
                 $this->HeaderBeginHTML = "<HTML><HEAD>";
                 $this->HeaderEndHTML = "</HEAD>";
                 $this->Template = New Template();
                 $this->HeaderAdditional = "<link rel="stylesheet" type="text/css" href="../styles/style.css">";
                 /****************THIS NEXT LINE CAUSES AN ERROR **/
                 //$this->FooterHTML = "<table><tr><td>(c) Harvest Bible Chapel $year. All rights reserved.</td></tr></table></BODY></HTML>";
                 /************************************************/
                 $this->FooterHTML = "<table class="Bottom" id="BottomTable"><tr class="Bottom" id="BottomRow"><td class="Bottom" id="BottomText">(c) Harvest Bible Chapel $year. All rights reserved.</td></tr></table></BODY></HTML>";

                 // Set IsPublic based on Value in table;
                 // Set URL based on Value in table;

         &#125;
         else
                echo $npage ." is not a valid page";


         return $this;

        &#125;

        Function AddToHeader($additional)
        &#123;
         $this->HeaderAdditional .= $additional;
        &#125;

        Function GetHeader($title="")
        &#123;
         global $CURRENT_PAGE;

         $CURRENT_PAGE = $this->Name;
         if ($title <> "")
         &#123;
          $this->PageTitle = $title;
          $this->HeaderBeginHTML .= "<TITLE>" .$this->PageTitle ."</TITLE>";
         &#125;

         $this->HeaderHTML = $this->HeaderBeginHTML . $this->HeaderAdditional . $this->HeaderEndHTML . "<BODY>";
         // Add the banner;
         $this->HeaderHTML .= $this->Template->GetFrameHTML("BANNER");
         // Add the Navigation Bar;
         $this->HeaderHTML .= "<table class="NavBar"><tr class="NavBar" id="NavBarRow"><td class="NavBarRow" id="NavBarButton"><a href="variable_width.htm">News & Events</a></td><td class="NavBarRow" id="NavBarButton"><a href="variable_width.htm">My Personal Growth</a></td><td class="NavBarRow" id="NavBarButton"><a href="variable_width.htm">My Small Group</a></td><td class="NavBarRow" id="NavBarButton"><a href="variable_width.htm">Small Group Leader</a></td><td class="NavBarRow" id="NavBarButton"><a href="variable_width.htm">Harvest Host</a></td></tr></table>";
         // Add the Sub-Navigation Bar;
         $this->HeaderHTML .= "<table class="SubNav"><tr class="SubNav" id="SubNavRow"><td class="SubNavRow" id="SubNavButton"><a href="variable_width.htm">Classes</a></td><td class="SubNavRow" id="SubNavButton"><a href="variable_width.htm">Events</a></td><td class="SubNavRow" id="SubNavButton"><a href="variable_width.htm">School of Ministry</a></td><td class="SubNavRow" id="SubNavButton"><a href="variable_width.htm">Off-site</a></td></tr></table>";
         Return $this->HeaderHTML;
        &#125;

        Function GetFooter()
        &#123;
         Return $this->FooterHTML;
        &#125;

        Function GetTitleHTML($proper, $functionTitle)
        &#123;
         $this->TitleHTML = "";
         $this->TitleHTML .= "<TABLE WIDTH=100%><TR><TD><H1>" .$proper ."</H1></TD></TR>";
         $this->TitleHTML .= "<TR><TD><HR ALIGN=LEFT WIDTH=75%></TD></TR>";
         $this->TitleHTML .= "<TR><TD><H3>" .$functionTitle ."</H3></TD></TR></TABLE>";

         return $this->TitleHTML;

        &#125;

        /*
        Function GetPath($dirName, $path="")
        &#123;
         $d = dir($dirName);
         echo $d->path;
         echo $d->handle;
         while($path == "" && $entry = $d->read())
         &#123;
          echo $entry;
          if ($entry != "." && $entry != "..")
          &#123;
           if (is_dir($dirName."/".$entry))
            $path = $this->GetPath($dirName."/".$entry);
           else
           &#123;
            if ($entry == $this->Name)
                $path = $dirName."/".$entry;
           &#125;
          &#125;
         &#125;
        $d->close();
        return $path;
        &#125;
        */

        Function GetLinkHTML($LinkDescr, $extraParams="")
        &#123;
          /*
          $path = $this->GetPath(".");
          $len = strlen($path);
          $finaldir = substr($path, 2, $len);
          //$html = "<a href="http://localhost/" .$finaldir .$extraParams ."">" .$LinkDescr ."</a>";
          $html = "<a href="http://www.harvestsmallgroups.org/" .$finaldir .$extraParams ."">" .$LinkDescr ."</a>";
          */

          //Check for user permissions;

          //$html = "<a href="http://www.harvestsmallgroups.org/" .$this->Name .$extraParams ."">" .$LinkDescr ."</a>";
          $html = "<a href="http://localhost/" .$this->Name .$extraParams ."">" .$LinkDescr ."</a>";

          return $html;
        &#125;

        /*
        Function UserAuthorized($User);
        Function PermAuthorized($Permission);
        */


        Function BeginTemplate()
        &#123;
         $TemplateHTML = "<table class="Body"><tr><td class="Body" id="BodyContent">";
         return $TemplateHTML;
        &#125;

        Function BeginBody($Title="Page Title")
        &#123;
         $MainHTML = "<table class="BodyContent" id="BodySection"><tr><td class="BodySection" id="BodyTitle">" .$Title ."</td></tr>";
         return $MainHTML;
        &#125;

        Function EndBody()
        &#123;
         $EndMainHTML = "</Table></td>";
         return $EndMainHTML;
        &#125;

        Function BeginBodySection($Title="Section Title")
        &#123;
         $MainSectionHTML = "<tr><td class="BodySection" id="BodySubTitle">" .$Title ."</td></tr><tr><td class="BodySection" id="BodyText">";
         return $MainSectionHTML;
        &#125;

        Function EndBodySection()
        &#123;
         $EndSection = "</td></tr>";
         return $EndSection;
        &#125;

        Function BeginSideBar($Title="SideBar Title")
        &#123;
         $sideBarHTML = "<td class="Body" id="BodySidebar"><table class="BodySidebar" id="SidebarTable"><tr><td class="SidebarTable" id="SidebarTitle">" .$Title ."</td></tr>";
         return $sideBarHTML;
        &#125;

        Function EndSideBar()
        &#123;
         $endSideHTML = "</table></td>";
         return $endSideHTML;
        &#125;

        Function BeginSideBarSection($Title, $pageLink="")
        &#123;
         if ($pageLink=="")
         $beginSideBarHTML = "<tr><td class="SidebarTable" id="SidebarBody"><b>" .$Title ."</b><p>";
         else
         &#123;
          $pageNew = GetPage($pageLink);
          $beginSideBarHTML = "<tr><td class="SidebarTable" id="SidebarBody"><p>" .$pageNew->GetLinkHTML($Title) ."<p>";
         &#125;
        return $beginSideBarHTML;

        &#125;

        Function EndSideBarSection()
        &#123;
         $endSideBarHTML = "</td></tr>";
         return $endSideBarHTML;
        &#125;

        Function EndTemplate()
        &#123;
         $endTemplateHTML = "</tr></table>";
         return $endTemplateHTML;
        &#125;

&#125;


Class Template
&#123;
        Var $Template;   //Template ID;
        Var $Frame;      //Array of HTML;
        Var $MainHTML;
        Var $SideHTML;
        Var $BannerURL;

        Function Template()
        &#123;
         $this->Template = 1;
         $this->Frame&#1111;"BANNER"] = "<table class="Top" id="TopTable"><tr class="TopTable" id="TopBanner"><td class="TopBanner" id="TopLogo"><img border="0"src="../images/Banner.gif" width="510" height="46"></td><td class="TopBanner" id="TopCenter"></td><td class="TopBanner" id="TopRight"><a href="login.php">Login</a></td></tr></table>";
         $this->Frame&#1111;"NAV"] = "Main Nav";
         $this->Frame&#1111;"SUBNAV"] = "Sub Nav";
         $this->Frame&#1111;"MAIN"] = "Main Form";
         $this->Frame&#1111;"SIDE"] = "Side Bar Form";
         return $this;
        &#125;

        Function SetTemplate($nNewTemplate)
        &#123;
         $this->Template = $nNewTemplate;
         // This also needs to load the template format into the frame array;
        &#125;

        Function SetFrameHTML($sFrame, $sNewHTML)
        &#123;
         $this->Frame&#1111;$sFrame] = $sNewHTML;
        &#125;

        Function GetFrameHTML($sFrame)
        &#123;
         $html = $this->Frame&#1111;$sFrame];
         return $html;
        &#125;


        Function GetFrames()
        &#123;
         //Return an array of all the frames;
         //Copy an associative array into a new array - just the keys;
        &#125;


&#125;

?>