Solved

why doesn't this php code work

Posted on 2003-12-05
15
329 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

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

Industry Leaders: 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!

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

717 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