Jump to content

Parse Values from one php file to another file


shalli

Recommended Posts

Hi there

 

I am stuck on a small php problem  :'( :'( :'( :'( :'(- I would like the address and contact no of the company to be displayed through out the site but controlled via a php file called contact.php - so that if the address or number changes I would only have to change one value in the contact.php file.

 

This is the example of my code

 

<?php

$formAction = '/call-back/';

 

include("contact.php");

 

?>

<div id="mainTop">

    <div id="mainTopLeft">

        <h1>Request A Callback</h1>

        <p>

            If this matter is urgent and you need to speak to an advisor immediately <br />please call <strong><?php echo $franchiseSiteAddress; ?></strong>

        </p>

 

and the contact.php file is

 

<?php

//contact details

 

//Franchise Site

$franchiseSiteAddress = "Suite D";

$franchiseSiteAddress1 = "Wyvern House";

$franchiseSiteAddress2 = "173, Filey Road";

$franchiseSiteAddress3 = "";

$franchiseSiteLocality = "Scarborough";

$franchiseSitePostcode = "North Yorkshire";

$franchiseSiteCountryName = "YO11 3AE";

$franchiseSiteContactNo = "01904 295 555";

 

//make the variables global

 

global $franchiseSiteAddress

global $franchiseSiteAddress1

global $franchiseSiteAddress2

global $franchiseSiteLocality

global $franchiseSitePostcode

global $franchiseSiteCountryName

global $franchiseSiteContactNo

 

?> 

... and the problem is?

 

Edit

 

Noticed this block:

 

global $franchiseSiteAddress
global $franchiseSiteAddress1
global $franchiseSiteAddress2
global $franchiseSiteLocality
global $franchiseSitePostcode
global $franchiseSiteCountryName
global $franchiseSiteContactNo

 

1) You're missing a semi-colon after each declaration

2) Declaring them in the scope you have they're already global

Well as I mentioned before that block of code is superfluous, declaring the variables globally [as you have] makes them global already. Try adding this to the top of your file and check if an error is being triggered:

 

ini_set('display_errors', 1);
error_reporting(E_ALL);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.