Closed Thread Icon

Topic awaiting preservation: PHP Template Help (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=22571" title="Pages that link to Topic awaiting preservation: PHP Template Help (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP Template Help <span class="small">(Page 1 of 1)</span>\

 
ngreed
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2003

posted posted 07-15-2004 18:00

I am trying to make a site using http://www.gurusnetwork.com/tutorial/php_templates/ I got it to work for one part of my site http://ngreed.theeamigos.net/ but when I tried it on another part of my site I got an error, http://www.theeamigos.net/NewSite/ Any help would be greatly appericiated.

Nick Greed (aka toolman)
ngreed@theeamigos.net
TheeAmigos Network Webmaster
Nerd For Christ
http://www.theeamigos.net

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 07-15-2004 18:15

Would you mind posting the code? From first look it might be that you are not including the correct type of path.

You would need something to the effect of include($_SERVER['DOCUMENT_ROOT'] . "/" . $page);

This tutorial was written a long time ago, and is only of value for historic purposes, it should probably be removed because it isn't the best way of doing things.

http://www.gurusnetwork.com/tutorial/php_templates_2/

I was very young in programming when I wrote the first one. The second one is a much better way of doing things when you have static content. (Note: the first method is useful for database driven content, where you would pull in a page from a database). I would however change $DOCUMENT_ROOT to $_SERVER['DOCUMENT_ROOT']; as using $DOCUMENT_ROOT is depricated (and unsafe).

Dan @ Code Town

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-15-2004 22:01

It looks like you are trying to use URL paths to open files.

this:

Warning: main(/pages/about.htm): failed to open stream: No such file or directory in /home/virtual/site175/fst/var/www/html/NewSite/index.php on line 93


means that you are looking for /pages/about.htm at the root level of your server (where /home is)

when it should be probably something like

fopen("/home/virtual/site175/fst/var/www/html/NewSite/pages/about.htm")

It's the difference between the filesystem on the server and the directory structure of your URLs.

You should use server variables like $_SERVER['DOCUMENT_ROOT'], and $_SERVER['PATH_TRANSLATED'] or a function like getcwd() to find out where you script is located in reference to the file system.



.:[ Never resist a perfect moment ]:.

ngreed
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2003

posted posted 07-15-2004 23:53

Here is the source code for the NewSite that is not working index.php

code:
<?php
if ($link == contact){
$page="pages/contact.php";
}
elseif($link == news){
$page="pages/news.htm";
}
elseif($link == links){
$page="pages/links.htm";
}
elseif($link == photo){
$page="pages/photo_gallery.htm";
}
elseif($link == mail){
$page="/squirrelmail/";
}
else{
$page="/pages/about.htm";
}
?>
<html>
<head>
<title>Thee Amigos Network</title>
<style type="text/css">
BODY{
scrollbar-face-color:#E6E6E6;
scrollbar-arrow-color:#000000;
scrollbar-track-color:#ffffff;
scrollbar-shadow-color:#000000;
scrollbar-highlight-color:#000000;
scrollbar-3dlight-color:#E6E6E6;
scrollbar-darkshadow-Color:#E6E6E6;
}
-->
</STYLE>
</head>
<body bgcolor="#C0C0C0" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<p align="center">
<script language="javascript">
<!-- Begin
d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);

today = new Date();
day = today.getDate();
year = today.getYear();

if (year < 2000)
year = year + 1900;

end = "th";
if (day==1 || day==21 || day==31) end="st";
if (day==2 || day==22) end="nd";
if (day==3 || day==23) end="rd";
day+=end;

document.write(" ");
document.write(d[today.getDay()]+" "+m[today.getMonth()]+" ");
document.write(day+", " + year);
document.write(" ");
// End -->
</script>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="3"><h1><center>Thee Amigos Network</center></h1></td>
</tr>
<tr>
<td align="center" valign="top">
<a href="index.php?link=About"> About </a>
</td>
</table>
<?php include($page); ?>
</body>
</html>



Nick Greed (aka toolman)
ngreed@theeamigos.net
TheeAmigos Network Webmaster
Nerd For Christ
http://www.theeamigos.net

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-16-2004 05:23

/pages/about.htm

should be

pages/about.htm



.:[ Never resist a perfect moment ]:.

ngreed
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2003

posted posted 07-16-2004 15:14
quote:
bitdamaged said:

/pages/about.htm

should be

pages/about.htm



.:[ Never resist a perfect moment ]:.



I made that change and I still get this error:

Warning: main(pages/about.htm): failed to open stream: Permission denied in /home/virtual/site175/fst/var/www/html/NewSite/index.php on line 93

Warning: main(): Failed opening 'pages/about.htm' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site175/fst/var/www/html/NewSite/index.php on line 93

Nick Greed (aka toolman)
ngreed@theeamigos.net
TheeAmigos Network Webmaster
Nerd For Christ
http://www.theeamigos.net

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 07-16-2004 15:31

-

(Edited by WarMage on 07-16-2004 15:33)

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 07-16-2004 15:32

You 1st need to modify your if/else block to quote the statics. i.e. news -> "news" or 'news'

Then you will need to change your include block to read include($_SERVER['DOCUMENT_ROOT'] . $page); and you will need to clean up your firest forward slash issue. Either you use them, and you add the slash to all entities in the top. Or you can neglect them and add it to the include (include($_SERVER['DOCUMENT_ROOT'] . "/" . $page);)

Good luck, it might be a good idea for you to go back to the basics and read through the PHP documentation. These mistakes will be cleared up when you have a complete understanding of the basics of the language.

Dan @ Code Town

(Edited by WarMage on 07-16-2004 15:33)

ngreed
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2003

posted posted 07-24-2004 02:56
code:
<?php
if ($link == contact){
$page="pages/contact.php";
}
elseif($link == news){
$page="pages/news.htm";
}
elseif($link == links){
$page="pages/links.htm";
}
elseif($link == photo){
$page="pages/photo_gallery.htm";
}
elseif($link == mail){
$page="squirrelmail/";
}
else{
$page="pages/about.htm";
}
?>
<html>
<head>
<title>Thee Amigos Network</title>
<style type="text/css">
BODY{
scrollbar-face-color:#E6E6E6;
scrollbar-arrow-color:#000000;
scrollbar-track-color:#ffffff;
scrollbar-shadow-color:#000000;
scrollbar-highlight-color:#000000;
scrollbar-3dlight-color:#E6E6E6;
scrollbar-darkshadow-Color:#E6E6E6;
}
-->
</STYLE>
</head>
<body bgcolor="#C0C0C0" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<p align="center">
<script language="javascript">
<!-- Begin
d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);

today = new Date();
day = today.getDate();
year = today.getYear();

if (year < 2000)
year = year + 1900;

end = "th";
if (day==1 || day==21 || day==31) end="st";
if (day==2 || day==22) end="nd";
if (day==3 || day==23) end="rd";
day+=end;

document.write(" ");
document.write(d[today.getDay()]+" "+m[today.getMonth()]+" ");
document.write(day+", " + year);
document.write(" ");
// End -->
</script>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="3"><h1><center>Thee Amigos Network</center></h1></td>
</tr>
<tr>
<td align="center" valign="top">
<a href="index.php?link=About"> About </a>
</td>
</table>
<?php include($_SERVER['DOCUMENT_ROOT'] . $page); ?>
</body>
</html>



I changed the include and I am still getting the same error

Nick Greed (aka toolman)
ngreed@theeamigos.net
TheeAmigos Network Webmaster
Nerd For Christ
http://www.theeamigos.net

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 07-24-2004 06:37

You didn't add the "/"

Dan @ Code Town

ngreed
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2003

posted posted 07-27-2004 03:13

Either Way, I get the same error

Nick Greed (aka toolman)
ngreed@theeamigos.net
TheeAmigos Network Webmaster
Nerd For Christ
http://www.theeamigos.net

« BackwardsOnwards »

Show Forum Drop Down Menu