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????
Getting strange parse error
Moderator: General Moderators
Tried a couple things
It was originally this
But I have also tried these:
And lastly I just put my file in the same folder as the include and did this, but it still didnt work:
What is the normal unix-based path to do this???
Code: Select all
include_once("../include/Page.inc.php");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");Code: Select all
include_once("Page.inc.php");Rediculous error - Found Solution
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.
Once I deleted this rem statement, everything worked fine.
ok - here is the file
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)
{
$pPage = New Page($sPageName);
Return $pPage;
}
Class Page
{
/* 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)
{
//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)
{
$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;
}
else
echo $npage ." is not a valid page";
return $this;
}
Function AddToHeader($additional)
{
$this->HeaderAdditional .= $additional;
}
Function GetHeader($title="")
{
global $CURRENT_PAGE;
$CURRENT_PAGE = $this->Name;
if ($title <> "")
{
$this->PageTitle = $title;
$this->HeaderBeginHTML .= "<TITLE>" .$this->PageTitle ."</TITLE>";
}
$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;
}
Function GetFooter()
{
Return $this->FooterHTML;
}
Function GetTitleHTML($proper, $functionTitle)
{
$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;
}
/*
Function GetPath($dirName, $path="")
{
$d = dir($dirName);
echo $d->path;
echo $d->handle;
while($path == "" && $entry = $d->read())
{
echo $entry;
if ($entry != "." && $entry != "..")
{
if (is_dir($dirName."/".$entry))
$path = $this->GetPath($dirName."/".$entry);
else
{
if ($entry == $this->Name)
$path = $dirName."/".$entry;
}
}
}
$d->close();
return $path;
}
*/
Function GetLinkHTML($LinkDescr, $extraParams="")
{
/*
$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;
}
/*
Function UserAuthorized($User);
Function PermAuthorized($Permission);
*/
Function BeginTemplate()
{
$TemplateHTML = "<table class="Body"><tr><td class="Body" id="BodyContent">";
return $TemplateHTML;
}
Function BeginBody($Title="Page Title")
{
$MainHTML = "<table class="BodyContent" id="BodySection"><tr><td class="BodySection" id="BodyTitle">" .$Title ."</td></tr>";
return $MainHTML;
}
Function EndBody()
{
$EndMainHTML = "</Table></td>";
return $EndMainHTML;
}
Function BeginBodySection($Title="Section Title")
{
$MainSectionHTML = "<tr><td class="BodySection" id="BodySubTitle">" .$Title ."</td></tr><tr><td class="BodySection" id="BodyText">";
return $MainSectionHTML;
}
Function EndBodySection()
{
$EndSection = "</td></tr>";
return $EndSection;
}
Function BeginSideBar($Title="SideBar Title")
{
$sideBarHTML = "<td class="Body" id="BodySidebar"><table class="BodySidebar" id="SidebarTable"><tr><td class="SidebarTable" id="SidebarTitle">" .$Title ."</td></tr>";
return $sideBarHTML;
}
Function EndSideBar()
{
$endSideHTML = "</table></td>";
return $endSideHTML;
}
Function BeginSideBarSection($Title, $pageLink="")
{
if ($pageLink=="")
$beginSideBarHTML = "<tr><td class="SidebarTable" id="SidebarBody"><b>" .$Title ."</b><p>";
else
{
$pageNew = GetPage($pageLink);
$beginSideBarHTML = "<tr><td class="SidebarTable" id="SidebarBody"><p>" .$pageNew->GetLinkHTML($Title) ."<p>";
}
return $beginSideBarHTML;
}
Function EndSideBarSection()
{
$endSideBarHTML = "</td></tr>";
return $endSideBarHTML;
}
Function EndTemplate()
{
$endTemplateHTML = "</tr></table>";
return $endTemplateHTML;
}
}
Class Template
{
Var $Template; //Template ID;
Var $Frame; //Array of HTML;
Var $MainHTML;
Var $SideHTML;
Var $BannerURL;
Function Template()
{
$this->Template = 1;
$this->Frameї"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ї"NAV"] = "Main Nav";
$this->Frameї"SUBNAV"] = "Sub Nav";
$this->Frameї"MAIN"] = "Main Form";
$this->Frameї"SIDE"] = "Side Bar Form";
return $this;
}
Function SetTemplate($nNewTemplate)
{
$this->Template = $nNewTemplate;
// This also needs to load the template format into the frame array;
}
Function SetFrameHTML($sFrame, $sNewHTML)
{
$this->Frameї$sFrame] = $sNewHTML;
}
Function GetFrameHTML($sFrame)
{
$html = $this->Frameї$sFrame];
return $html;
}
Function GetFrames()
{
//Return an array of all the frames;
//Copy an associative array into a new array - just the keys;
}
}
?>