Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

why doesn't this php code work

Posted on 2003-12-05
15
Medium Priority
?
332 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
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!

 

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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

604 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