Solved

why doesn't this php code work

Posted on 2003-12-05
15
324 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 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 …

770 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