shalli Posted April 15, 2010 Share Posted April 15, 2010 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/ Share on other sites More sharing options...
Adam Posted April 15, 2010 Share Posted April 15, 2010 ... 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 Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042363 Share on other sites More sharing options...
shalli Posted April 15, 2010 Author Share Posted April 15, 2010 Hi Mr Adam Everytime I run the script the page is blank that why I dont understand where the problem is. I have added the semicolons but this hasnt made a difference Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042365 Share on other sites More sharing options...
Adam Posted April 15, 2010 Share Posted April 15, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042382 Share on other sites More sharing options...
shalli Posted April 15, 2010 Author Share Posted April 15, 2010 hI Mr Adam Still blank page I am afraid I have heard the sessions are the best way to use variables defined from other page would that be better then using a global value Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042432 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 The global lines are not needed. Remove them. Are you including the right path to the contact.php? Can you add this above your include line? echo file_exists('contact.php')? 'Yes' : 'No'; What does that echo? Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042438 Share on other sites More sharing options...
shalli Posted April 15, 2010 Author Share Posted April 15, 2010 Hi Ken2k7 The response is NO Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042529 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Then you got the include path wrong. Quote Link to comment https://forums.phpfreaks.com/topic/198633-parse-values-from-one-php-file-to-another-file/#findComment-1042566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.