PHP and <gasp> meta tags

They have: 42 posts

Joined: Jan 2005

Hi. I am trying to get my index.php to include the index.php in my /exchange directory. No problems... until I tried to add META tags.

Here's what I've got now:

<?php
include('exchange/index.php');
?>

I'd like it to be the below so I have meta tags, but am having no luck:

<?php
include('exchange/index.php');
?>

I get this error at the top of the page:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/bannerad/public_html/index.php:7) in /home/bannerad/public_html/exchange/index.php on line 2

How can I add the make the index of /exchange the index of the site and have meta tags?!

Thanks so much

James

They have: 161 posts

Joined: Jan 2005

Hi that's easy. First off your php web page should ONLY look like this:

<?php
include('exchange/header.php');
?>
<?php
include('exchange/index.php');
?>

Now, make a header.php file in your exchange folder, and put all the opening HTML tags into that. Then at the end of your index.php you can close everything off with

k?

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

The problem is (even in dynamite's suggestion) will be that it looks like you are starting a session inside of exchange/index.php. Sessions can only be started if no other information has been sent to the broswer yet.

You will either need to move the code to start the session to your main index.php file, or take the code from the main index.php file, assign that to a variable, and then in the exchange/index.php file print that string out AFTER you start the session.

Now, are we to assume that the exchange/index.php doesn't output anything to the browser? from the code you gave, you have the closing tag before you call exchange/index.php, so nothing else should go out to the browser at that point.

-Greg

They have: 161 posts

Joined: Jan 2005

here's a live EXAMPLE of what i was claiming Cool
http://www.kingoftheweb.net

(still workin on it, but u get the drift)

if u need help just PM me

CptAwesome's picture

He has: 370 posts

Joined: Dec 2004

It's not showing the error on the page any more.
If you're still having the problem, look at php's ob_start() and the subsequent functions. These allow you to put the order anyway you like, as long as the session_start is outside the buffer, and everything else is in it.

An example would be:

<?php ob_start(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Description" content="The most popular free banner exchange: drive targeted traffic to your site with our excellent ratio of 4:3!">
<meta name="Keywords" content="banner exchange,free traffic,traffic,banners,advertising,free advertising,reciprocal linking,free banner exchange,more visitors">
</head>
</html>
<?php
include('exchange/index.php');
ob_end_flush();
?>
'

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.