Solved

why doesn't this php code work

Posted on 2003-12-05
15
328 Views
Last Modified: 2008-03-06
I'm a first timer here.  I've searched through several other people's quesitons that are similar but I cannot figure out why this doesn't work.

<HTML>
<HEAD>
<TITLE> My First Php page </TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
</HEAD>

<BODY>
<?php
include("head.html");
?>
<!-- Table for Main Body -->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td valign=top align=left width="90">
<?php
include ("menu.html");
?>
</td>
<td width="1" bgcolor="blue" valign=top>  </td>
<td valign=top>

<?php
include ("page1body.html");
?>
<br> <br>
<?php
include ("menu2.html");
?>
</td>
<td width="1" bgcolor="blue" valign=top>   </td>
</tr></table>

</BODY></HTML>
0
Comment
Question by:AWP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 4
15 Comments
 
LVL 6

Expert Comment

by:rjdown
ID: 9884169
The HTML and PHP tags appears to be correct, please be more specific. What do you mean "it doesn't work"?

Are the include pages in the same directory as your main page?
0
 
LVL 6

Expert Comment

by:rjdown
ID: 9884181
Hmm as an afterthought, are you sure PHP is installed on your server?
0
 

Author Comment

by:AWP
ID: 9884190
I know that one of my other domains uses a php shopping cart and it works fine.  I've also noticed that is has a mysql database configurd with it.  I am not sure that I have everything configured properly on this domain.  But the server has it installed properly.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:AWP
ID: 9884195
the include pages are in the same directory as the main page.

When I say it doesn't work I mean that when I pull up the index.php all I see is a white page with 2 blue likes that are the background colors for he left and right margins.  No header, no footer, no body comes up.
0
 
LVL 6

Expert Comment

by:rjdown
ID: 9884209
Could you post the contents of one or all of your includes here. The problem may lie within those.
0
 

Author Comment

by:AWP
ID: 9884266
the menu.html


<html>

<head>


<title>New Page 5</title>
</head>

<body>

[<a href="index.php">Home </a>]
[<a href="page2.php">Page 2</a>]
[<a href="page3.php">Page 3</a>]
[<a href="page4.php">Page 4</a>]


</body>

</html>


I looked at one tutorial that said to leave out the html & body tags on the includes pages.  I've tried that also and I received the same response.
0
 
LVL 6

Expert Comment

by:rjdown
ID: 9884333
Indeed you should leave out html, head, title and body tags, but this is simply good practice and will not affect your output.

I have put your code onto my server and it works fine. Can you try this in your index.php:

replace

include("menu.html");

with

echo "menu.html";

and likewise with the other includes.

This is just a test to make sure your PHP engine is working, and will simply print the text "menu.html" for example, instead of the actual menu.

If it works, there is a problem with your PHP settings, and I will explain further what you need to do.
If it doesn't work, your PHP engine is either broken or missing.
0
 
LVL 2

Expert Comment

by:HeadAcheMike
ID: 9884607
your include tags are wrong should be

include('file.html');

Not

include("file.html")
0
 
LVL 2

Accepted Solution

by:
HeadAcheMike earned 500 total points
ID: 9884620
try it like this, should fix your problem:

<HTML>
<HEAD>
<TITLE> My First Php page </TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
</HEAD>

<BODY>
<?php
include('head.html');
?>
<!-- Table for Main Body -->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td valign=top align=left width="90">
<?php
include ('menu.html');
?>
</td>
<td width="1" bgcolor="blue" valign=top>  </td>
<td valign=top>

<?php
include ('page1body.html');
?>
<br> <br>
<?php
include ('menu2.html');
?>
</td>
<td width="1" bgcolor="blue" valign=top>   </td>
</tr></table>

</BODY></HTML>
0
 
LVL 6

Expert Comment

by:rjdown
ID: 9884624
" and ' are both valid..at least on my box (PHP version 4.3.3)
0
 
LVL 2

Expert Comment

by:HeadAcheMike
ID: 9885064
i had once assumed that but ive come accross a couple of people who have had problems with the double quote, worth trying nevertheless
0
 
LVL 6

Expert Comment

by:rjdown
ID: 9885076
Fair nuff :D
0
 

Author Comment

by:AWP
ID: 9885689
it still appears the same.  how do i confirm if php is properly installed on the domain?
0
 
LVL 2

Expert Comment

by:HeadAcheMike
ID: 9885756
put this in a file and exeucute it

<?php
php_info();
?>

if it is installed then it will give you all of the php installation information
0
 
LVL 2

Expert Comment

by:HeadAcheMike
ID: 9885811
and one other thing if you are not aware of this, any files that contain php code must have the extension .php instead of .html
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
curl parse data from site 20 62
geting data from the array list 6 36
How to display get_the_terms within a function 3 38
phpmyadmin memory error 55 90
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question