Php calling one .php file from another (Simple error)

Hello, I’ve been having this error with my code and i’ve literally been struggling with it relentlessly for the past couple of hours and i just can’t see it. My experiences so far with php have been, “You’re missing a simple period here on line 43,” and I just can’t see this error for the life of me. I just need someone to push me in the right direction at the very least, any help is appreciated and even if you don’t know a push in the right direction is welcomed.
index.php
[php]

<?php require_once('Company.php'); $companyobject = new Company(); if (!empty($_REQUEST['debug'])) { $debug = true; } else { $debug = false; } /*************************** Function Declaration ********************/ /* function display_company_name($firstName){ echo "

$firstName

"; } function display_company_address(){ global $company_name,$company_address,$company_citystatezip; print "$company_name,$company_address,$company_citystatezip"; } */

create array for a Real Estate Web site

/*************************** Function Declaration ********************/

print $companyobject->getHeader($company_name,$color);
$companyobject->create_array_carpet();
$companyobject->displayProduct($carpet_array);
print $companyobject->getFooter($color);
if($debug==true){
print “Lab 3 successful!”;
}

?>

Debug OFF Debug ON [/php] Company.php [php] <?php class Company{ var $company_name = "Billy May's Carpets"; var $company_address = "25309 Ave Ronada "; var $company_citystatezip = "Valencia California, 91355"; function getHeader($company_name,$color){ $color .= "

$this->company_name

"; $color = $color . ""; return $color; } function getFooter($color){ $color .= "

$this->company_name,$this->company_address,$this->company_citystatezip

"; $color = $color . ""; return $color; } function displayProduct($array){ for($i=0;$i<count($array);$i++){ print "$array[$i]"; print "
"; } function create_array_carpet ( ) { global $carpet_array; $carpet_array = array(); $carpet_array[] = "ID: MLS123, Carpet: Brown, $650000.00, per 15 feet of carpet" ; $carpet_array[] = "ID: MLS456, Carpet: Blue, $199950.00, per 15 feet of carpet" ; $carpet_array[] = "ID: MLS789, Carpet: Green, $799950.00, per 15 feet of carpet" ; $carpet_array[] = "ID: MLS654, Carpet: Black, $599900.00, per 15 feet of carpet" ; } } ?> [/php]

I don’t seem to see an edit button but this is the error i’m encountering
Parse error: syntax error, unexpected ‘;’, expecting T_FUNCTION in /srv/disk6/1359777/www/andrew.mathium.net/Company.php on line 33

Check your brackets. Right here this would be a nested function and class Company { would have no closing bracket

[php]
function displayProduct($array){
for($i=0;$i<count($array);$i++){
print “$array[$i]”;
print “
”;
}
function create_array_carpet ( ) {
global $carpet_array;
$carpet_array = array();
$carpet_array[] = “ID: MLS123, Carpet: Brown, $650000.00, per 15 feet of carpet” ;
$carpet_array[] = “ID: MLS456, Carpet: Blue, $199950.00, per 15 feet of carpet” ;
$carpet_array[] = “ID: MLS789, Carpet: Green, $799950.00, per 15 feet of carpet” ;
$carpet_array[] = “ID: MLS654, Carpet: Black, $599900.00, per 15 feet of carpet” ;
}
}
[/php]

I believe should be

[php]
function displayProduct($array){
for($i=0;$i<count($array);$i++){
print “$array[$i]”;
print “
”;
}
}
function create_array_carpet ( ) {
global $carpet_array;
$carpet_array = array();
$carpet_array[] = “ID: MLS123, Carpet: Brown, $650000.00, per 15 feet of carpet” ;
$carpet_array[] = “ID: MLS456, Carpet: Blue, $199950.00, per 15 feet of carpet” ;
$carpet_array[] = “ID: MLS789, Carpet: Green, $799950.00, per 15 feet of carpet” ;
$carpet_array[] = “ID: MLS654, Carpet: Black, $599900.00, per 15 feet of carpet” ;
}
}
[/php]

I actually found this out after shortly after posting and ran into an entirely new problem haha. I’m going to try and take a couple of more approaches at it before i post again, regardless, thank you for looking!

As a pose to making a new thread, I’ve decided to post here again to avoid cluttering up the forum. I have another question regarding an issue with my webpage (not a syntax error) but rather a funky display and an issue with one of my functions… As usual here is the functioning code,
Index.php

[code]

<?php require_once('HouseSeller.php'); //$companyobject = new Company(); $houseobject= new HouseSeller(); ?> <?php print $houseobject->getHeader($houseobject->company_name,$houseobject->color); if (!empty($_REQUEST['debug'])) { $debug = true; } else { $debug = false; } /*************************** Function Declaration ********************/ /* function display_company_name($firstName){ echo "

$firstName

"; } function display_company_address(){ global $company_name,$company_address,$company_citystatezip; print "$company_name,$company_address,$company_citystatezip"; } */

create array for a Real Estate Web site

/*************************** Function Declaration ********************/

/*print $companyobject->getHeader($companyobject->company_name,$companyobject->color);
$companyobject->create_array_carpet();
$companyobject->displayProduct($carpet_array);
print $companyobject->getFooter($companyobject->color);
*/
//Display Problem Begins Here

”;
“”;
“”;
“”;
“”;
Left
”;
$houseobject->create_navbar_array(); // Makes its own tab on the left
print $houseobject->getLeftNavBar();

Bar
”;
$houseobject->create_array_carpet(); // Makes its own section in the middle
$houseobject->displayProduct($carpet_array); “
”;

//Ends Here
print $houseobject->getFooter($houseobject->color);
if($debug==true){
print “Lab 3 successful!”;
}

?>

Debug OFF Debug ON [/code] Company.php [code]<?php class Company{ var $company_name = "Billy May's Carpets"; var $company_address = "25309 Ave Ronada "; var $company_citystatezip = "Valencia California, 91355"; var $color = "
"; var $company_url= "http://www.college1.com/users/[email protected]"; var $company_email = "[email protected]"; function getHeader($company_name,$color){ $color .= "

$this->company_name

"; $color = $color . "
"; return $color; } function getFooter($color){ $color .= "

$this->company_name,$this->company_address,$this->company_citystatezip

"; $color = $color . ""; return $color; } function displayProduct($array){ for($i=0;$i<count($array);$i++){ print "$array[$i]"; print "
"; } } function create_array_carpet (){ global $carpet_array; $carpet_array = array(); $carpet_array[] = "ID: MLS123, Carpet: Brown, $650000.00, per 15 feet of carpet" ; $carpet_array[] = "ID: MLS456, Carpet: Blue, $199950.00, per 15 feet of carpet" ; $carpet_array[] = "ID: MLS789, Carpet: Green, $799950.00, per 15 feet of carpet" ; $carpet_array[] = "ID: MLS654, Carpet: Black, $599900.00, per 15 feet of carpet" ; } } ?>[/code] HouseSeller.php [code]<?php require_once('Company.php') ?> <?php class HouseSeller extends Company{ var $navbar_array; # create array for a Car/house/travel Nav Bar function create_navbar_array ( ) { $mainurl = $this->company_url; // get the main url address of this web page $this->navbar_array = array( "Home Page"=>"$mainurl?whichpage=home", "Sales"=>"$mainurl?whichpage=sales", "Support" => "$mainurl?whichpage=support", "Contacts" => "$mainurl?whichpage=contact" ); } function getLeftNavBar(){ foreach ( $this->navbar_array as $key=>$value ) { $this->navbar_array .= "$key
"; // Is taking the the word "array" proceeding the array and adding it into the mix, not sure how to amend that. } return $this->navbar_array; } } ?>[/code] Woops, i would post an image but its not allowing me to, the Left Tab is above the middle section tab and I'm unsure as to how to fix that.

Fixed the array problem, still working on the display problem… Sorry, if i could edit my posts i would as a pose to continually posting.

Sponsor our Newsletter | Privacy Policy | Terms of Service