Gandalf
Dec 20 2004, 11:20 PM
Hi for the first time.
Why will this not work!?
header.php file contains the following ONLY:
<?php echo $title; ?>
The index.php file contains this:
<title><?php $title='RCC'; include 'header.php'; ?></title>
But when i view this page, the Page Title in the browser window reads: <?php $title='RCC'; include 'header.php'; ?>
What is wrong here?
Gändälf
Joe
Dec 20 2004, 11:23 PM
Hey, welcome to the forums mate

Do both pages have a .php extension?
header.php<title><?php echo $title;?></title>
index.php<?php $title ="page title here"; include 'header.php'; ?>
HTH, Joe
Gandalf
Dec 20 2004, 11:30 PM
Yes, they do. Could the installation of the EasyPHP server and Apache been installed incorrectly??
Joe
Dec 20 2004, 11:35 PM
Notice the way my includes are set up? They are different to yours, this is why you are getting the error, try mine and then see what happens.
Joe
Dec 20 2004, 11:38 PM
Copy and paste these codes exactly as they are into notepads with the names given to each section:
header.phpPHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title><?php echo $title;?></title>
</head>
<body>
index.phpPHP
<?php $title ="page title here"; include 'header.php'; ?>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse vel urna. Donec ac orci eget urna suscipit facilisis. Praesent luctus tortor vitae quam. Praesent velit dolor, accumsan in, luctus adipiscing, rhoncus sed, erat. Proin lacus lectus, ornare non, tincidunt nec, condimentum sed, lorem. Nullam tempus, mauris nec pretium adipiscing, leo mauris cursus pede, eget imperdiet nunc libero non urna. Aliquam hendrerit justo in magna. Ut id risus. Aenean ut nisl eget purus pretium molestie. Cras lacus purus, aliquet eu, vulputate eu, fermentum sed, tortor. Etiam vitae velit id velit luctus scelerisque. Suspendisse aliquam tincidunt leo.</p>
</body>
</html>
Gandalf
Dec 20 2004, 11:40 PM
I'm guessing that you're in reference to your site and when I check out the source code on it the PHP code does not show up as it is not suppsoed to and this is all I get:
<title>Joe2Torials - HTML, CSS & Much More... \ PHP \ Includes</title>
What is perplexing is not so much the code as my inability to "get" what you are saying!
Thanks for keep trying though!
Gandalf
Dec 20 2004, 11:41 PM
okay
Joe
Dec 20 2004, 11:44 PM
QUOTE(Gandalf @ Dec 21 2004, 12:40 AM)
I'm guessing that you're in reference to your site and when I check out the source code on it the PHP code does not show up as it is not suppsoed to and this is all I get:
<title>Joe2Torials - HTML, CSS & Much More... \ PHP \ Includes</title>
What is perplexing is not so much the code as my inability to "get" what you are saying!
Thanks for keep trying though!

[right][snapback]20724[/snapback][/right]
Thats because the server handles all the PHP code and all you get is the outputted HTML version of the site. Remember my example showing you a PHP script without the .php extension? Well with the .php extension the code runs, all server side languages are processed by the server and then correctly processed, the HTML code is the formed and send to your browser (client side) which is what you see.
Simple see
Gandalf
Dec 20 2004, 11:45 PM
Two more quick questions:
1. (header.php page) Does that page (since it's going to be included) need all of that extra html? Why couldn't we simply get away with just the PHP code as in an external CSS page way?
1b. There is no closing </body></html> tags...why not?
2. (index.php page) Does this have to go Between the <title></title> section or does it replace those two tags? <?php $title ="page title here"; include 'header.php'; ?>
Joe
Dec 20 2004, 11:46 PM
[snapback]20723[/snapback] <-- PHP (server side code)
HTML outputted code (client side)CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>page title here</title>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse vel urna. Donec ac orci eget urna suscipit facilisis. Praesent luctus tortor vitae quam. Praesent velit dolor, accumsan in, luctus adipiscing, rhoncus sed, erat. Proin lacus lectus, ornare non, tincidunt nec, condimentum sed, lorem. Nullam tempus, mauris nec pretium adipiscing, leo mauris cursus pede, eget imperdiet nunc libero non urna. Aliquam hendrerit justo in magna. Ut id risus. Aenean ut nisl eget purus pretium molestie. Cras lacus purus, aliquet eu, vulputate eu, fermentum sed, tortor. Etiam vitae velit id velit luctus scelerisque. Suspendisse aliquam tincidunt leo.</p>
</body>
</html>
Joe
Dec 20 2004, 11:50 PM
QUOTE(Gandalf @ Dec 21 2004, 12:45 AM)
1. (header.php page) Does that page (since it's going to be included) need all of that extra html? Why couldn't we simply get away with just the PHP code as in an external CSS page way?
We may aswell give it all the header information (since it will be included on ALL pages anyway) because it saves on load times and bandwidth.
QUOTE(Gandalf @ Dec 21 2004, 12:45 AM)
1b. There is no closing </body></html> tags...why not?
Because it is only including that
part of the code, like a giant jigsaw so to speak.
QUOTE(Gandalf @ Dec 21 2004, 12:45 AM)
2. (index.php page) Does this have to go Between the <title></title> section or does it replace those two tags? <?php $title ="page title here"; include 'header.php'; ?>
Where it says include header, it take the information out of header.php and places it exactly on the page where the include is, the $title variable (stored with the title of the page) then gets outputted inside the <title> tags (as thats where we actually echo the variable (empty the box))
Gandalf
Dec 20 2004, 11:53 PM
Well, I did exactly as you said and it's not working. Mind if I zip you these two short pages to run on your server for testing?
Joe
Dec 20 2004, 11:55 PM
Yeah no problem
Gandalf
Dec 20 2004, 11:57 PM
attached*
Joe
Dec 21 2004, 12:02 AM
I see what you've done wrong, your writing the doctype etc on the index aswell, which you don't need too.
The whole purpose of the include is so you don't have to write the same information over and over again in loads of different pages. The include contains the one type of information (dctype, encryption, etc) and is then dynamically included onto all the pages, called by the include.
*attached
Gandalf
Dec 21 2004, 12:28 AM
Okay, I'm starting to see what you're getting at...though I've made this comment before...

In the index.php page that you updated there is no <body> start tag...why not?
REF:
------------------------------------------------------------------
< ?php $title ="page title here"; include 'header.php'; ?>
< !-- START: Page -->
< div id="main">
------------------------------------------------------------------
Gandalf
Dec 21 2004, 12:35 AM
I see you're offline, but that's fine. I'm going to get a few questions posted here in replies so you will have them when you return.
There were two <title></title> tag sections in the updated header.php; which one do I get rid of, because the title still is not showing up.
REF:
------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php $title ="page title here"; include 'header.php'; ?></title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="en-us" />
<link href="rcc-css.css" type="text/css" rel="stylesheet" />
<title><?php echo $title;?></title>
</head>
<body>
--------------------------------------------------------------------------
Gandalf
Dec 21 2004, 12:37 AM
So now since there will not be a DOCtype on every page there is no reason to try and validate these files over at W3C; mainly because they are PHP files??
Joe
Dec 21 2004, 11:21 AM
QUOTE(Gandalf @ Dec 21 2004, 01:28 AM)
In the index.php page that you updated there is no <body> start tag...why not?
REF:
------------------------------------------------------------------
< ?php $title ="page title here"; include 'header.php'; ?>
< !-- START: Page -->
< div id="main">
------------------------------------------------------------------
[right][snapback]20735[/snapback][/right]
The body start tag is inside the header thats why, it is included within that code, so when the jigsaw is put together the body will be at the top of index.php
QUOTE(Gandalf @ Dec 21 2004, 01:28 AM)
There were two <title></title> tag sections in the updated header.php; which one do I get rid of, because the title still is not showing up.
Oh yea, sorry I didn't see your header, remove your code.
<title><?php $title ="page title here"; include 'header.php'; ?></title> And keep my added one there.
QUOTE(Gandalf @ Dec 21 2004, 01:28 AM)
So now since there will not be a DOCtype on every page there is no reason to try and validate these files over at W3C; mainly because they are PHP files??
There will be a doctype on everypage, I don't think your quite grasping the concept of the include, the include makes the code from inside the included file appear on all the pages that it is included into appear on the page when called upon by the server, that will then output all the HTML. And you will see the code as you see it on my site.
HTH, Joe
Gandalf
Dec 21 2004, 10:15 PM
Okay, I'm starting to understand (wow! that is becoming cliche) the idea of a jigsaw puzzle... at this stage it seems i've bought one of these puzzles with missing pieces...or maybe those missing "pieces" are from something else...
I'm going to now attempt to explain back to you how this process works to see how far off balance I am in the head.
The first called (include) code on the index.php page is for the header.php. Inside the header.php source code the opening <body> exists thus starting the body content of the index.php page.
Now, next I would like to have a title-bar.php page. (yes i probably could merge this onto the header.php, but for the time being humor me on this) Now on the index.php page I will write <?php include 'title-bar.php'; ?> in it's appropriate place. On the title-bar.php page since the opening <body> tag has already been addressed in the header.php page all I should need on this page is merely the <div> tags if I am understanding this jigsaw puzzle right.
Can you verify this?
Thanks for your patience.
Just think how this will benefit your tutorial, since I represent a large confused crowd.
Gändälf
Joe
Dec 21 2004, 10:25 PM
QUOTE(Gandalf @ Dec 21 2004, 11:15 PM)
Now, next I would like to have a title-bar.php page. (yes i probably could merge this onto the header.php, but for the time being humor me on this) Now on the index.php page I will write <?php include 'title-bar.php'; ?> in it's appropriate place. On the title-bar.php page since the opening <body> tag has already been addressed in the header.php page all I should need on this page is merely the <div> tags if I am understanding this jigsaw puzzle right.
[right][snapback]20763[/snapback][/right]
title-bar? I'm guessing (on a normal html page) that this code would come directly after the <body> tag yes?
If so then no header tags needed, you can move straight onto body tags (div, span whatever!)
- Joe
Gandalf
Dec 21 2004, 10:32 PM
updated NON-working code attached
Gandalf
Dec 21 2004, 10:33 PM
the title bar is the logo fyi
Gandalf
Dec 21 2004, 11:03 PM
updated zip file attached
G
Joe
Dec 22 2004, 11:17 AM
Gandalf, do you think you could reduce the size of the image in your sig please

Your code looks fine, apart from in index.php you have
<link href="rcc-css.css" type="text/css" rel="stylesheet" /> which shouldn't be there (below the include).
Does it all work? What problems are you having?
Gandalf
Dec 22 2004, 08:48 PM
It's not working on my end at all!
Quick Q: Do the php pages have to be in the www base folder or could they (merely for example) be like this: www/php/index.php
Screen shot attached. You will see that there is no title in the title bar of the browser and also no logo bar (previously called title-bar).
G
Joe
Dec 22 2004, 09:05 PM
Yes, all of the PHP files must go into the WWW folder ... I suggest making a subfolder in this folder, something like:
C:\Program Files\Easy PHP\www\testing\
And then playing with your scripts in there.
Gandalf
Dec 22 2004, 09:07 PM
Well that was confusing...
they Must go in the www folder? but then you suggest creating a test folder for the scripts, but how would i be able to test them if they had to be in the www folder??
Joe
Dec 22 2004, 09:11 PM
When you open the WWW folder it shows (by default) index.php which shows a list of all files and folders currently inside the WWW folder. I just suggest creating a new folder inside the www folder so you can name your file index.php (instead of overwriting the already index.php in the folder)
Gandalf
Dec 22 2004, 09:13 PM
n/m I get it.
So in that screenshot why wouldnt the title appear in the title bar of the browser?
Joe
Dec 22 2004, 09:20 PM
I don't know tbh, does title-bar have the php extension?
<?php include 'title-bar.php'; ?>
Should work fine...
Gandalf
Dec 22 2004, 09:43 PM
haha @ i was waiting for your reply on the second page and kept waiting... what a loser! @ me
lol
Yeah, i'm pretty lost as to why this isn't working. I've even started over from scratch and the same problem occurs.
I don't think the installation of EasyPHP could have gone wrong, do you!??
Another question, you mentioned that the link to the external CSS page should not be below the <?php include ("header.php") ?> tag; can it be above it?
Anyway, I'm going to start this whole thing over from the basics and will drop a reply in a few minutes.
Thanks,
Gänd
Joe
Dec 22 2004, 09:49 PM
post your current .zip file here and I will take a look at your code, if all is fine then it must be EasyPHP
Gandalf
Dec 22 2004, 09:50 PM
Okay, starting over completely from scratch to simplify everything.
header.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $title;?></title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="en-us" />
<link href="rcc-css.css" type="text/css" rel="stylesheet" />
</head>
<body>
----------------
index.php
<?php $title="RCCs new site"; include 'header.php'; ?>
</body>
</html>
So what is wrong with this? Because the title doesnt work.
Joe
Dec 22 2004, 10:35 PM
That code is fine

On easy PHP does it show that both processes are running? Both Apache and MySQL ?
Joe
Dec 22 2004, 10:37 PM
The code you have just posted works fine for me...
Gandalf
Dec 22 2004, 10:50 PM
yes
ss attached*
Gandalf
Dec 22 2004, 10:56 PM
now what?
Joe
Dec 22 2004, 10:56 PM
Then I have no idea why it isn't working

It works fine on my computer ... can anyone else see a reason why this isn't working?
Joe
Dec 22 2004, 11:09 PM
Try re-installing EasyPHP and see if that makes a difference. I have exactly the same settings as you and am using the same folder / filenames and mine is working perfectly ... have you tried uploading the files to a working online server to test it?
Gandalf
Dec 22 2004, 11:10 PM
going to uplaod to the site for testing
Gandalf
Dec 22 2004, 11:13 PM
can you attach a screenshot of what my title bar looks like on your side?
Gandalf
Dec 22 2004, 11:24 PM
FOUND THE PROBLEM!!
Yay!
When I uploaded it to the server it works just fine. So I will uninstall/reinstall the software in attempt to fix this problem.
Arg!
Gändälf
Joe
Dec 23 2004, 01:34 AM
I told you the script was fine

Must be a hardware problem then, make sure this time you don't overwrite any files ... maybe that was the problem.
Gandalf
Dec 23 2004, 01:37 AM
Well, I uninstalled taht sucka and deleted everything in that DIR. Then I reinstalled the program and am starting from scratch since I hadn't got beyond the header.
This time EVERYTHING is working correctly and I can/am working on it just fine. I have no idea what was wrong with it...whatever "it" is referring to.
lol
Thank you for your help,
Gändälf

Happy Holidays!
Gandalf
Dec 23 2004, 05:10 AM
Woohoo! It works and I'm finally progressing and starting to code in PHP!!
Rock on!
Gänd
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.