howardmoore Posted May 22, 2009 Share Posted May 22, 2009 Hi, I am building a site using PHP includes to show a set bit of content on lots of pages (i.e. some standard repeating text). The problem is that when I call the include, all the data shown below where it appears is the same as the include, and not the main page that I am trying to call. Both the include and the page on which is sits need to call a field from a MySQL database called 'content'. Can anyone think of a workaround for this? Many thanks, Neil Quote Link to comment https://forums.phpfreaks.com/topic/159244-php-include-affecting-other-results-on-page/ Share on other sites More sharing options...
MadTechie Posted May 22, 2009 Share Posted May 22, 2009 So you have an include that calls "contents" and another one that calls "contents" ie Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello <?php include "databasecontents.php"; ?> Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello contents, contents, contents, contents, contents, contents, contents, WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD <?php include "databasecontents.php"; ?> WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD contents, contents, contents, contents, contents, contents, contents, so when you do this Main Main Main Main Main Main <?php include "page1.php"; include "page2.php"; ?> and you end up with Main Main Main Main Main Main Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello contents, contents, contents, contents, contents, contents, contents, WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD WORLD contents, contents, contents, contents, contents, contents, contents, if the above is the problem then you have a few solutions #1 use include_once("databasecontents.php") #2 break it up more ie Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello <?php include "databasecontents.php"; ?> Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello <?php include "page1.html"; include "databasecontents.php"; ?> then in main call include "page1.html"; instead of include "page1.php"; Quote Link to comment https://forums.phpfreaks.com/topic/159244-php-include-affecting-other-results-on-page/#findComment-839879 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.