Jump to content

Recommended Posts

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

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";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.