View Full Version : Starting out with PHP
0degree
05-06-2001, 06:59 PM
I've just started learning PHP and am already struggling!
I'm trying to create a page that uses the classical method of parsing header and footer files.
index.php includes:
<HTML>
<HEAD>
</HEAD>
<BODY>
<? include "/xdomain/www/inc/header.php" ?>
TEXT
TEXT
TEXT
<? include "/xdomain/www/inc/footer.php" ?>
</BODY>
</HTM>
header.php and footer.php include:
<?
print "
TEXT
TEXT
TEXT "
?>
Is this valid?[nbsp][nbsp]I tried using it but ended up with index.php loading but not containg header.php and footer.php.[nbsp][nbsp]When looking at the source code, I couldn't find any of the "include" lines mentioned above.[nbsp][nbsp]I also couldn't find any errors in the logs.[nbsp][nbsp]I've been trying to find what's wrong without success.[nbsp][nbsp]Any help is appreciated.
Arthur
05-07-2001, 04:21 AM
<? include "/xdomain/www/inc/header.php" ?> The path is invalid, you either have to include the full file path (<? include "/big/dom/xdomain/www/inc/header.php" ?>) or a relative path (<? include "inc/header.php" ?>).
HTH,
Arthur<!-- NO_AUTO_LINK -->
0degree
05-07-2001, 06:34 AM
Thanks for the help Arthur, I will give it a try.[nbsp][nbsp]What I did was follow the instructions at http://www.aota.net/PHP_and_MySQL/Getting_Started.php3
which suggests that the server will pre-pend the /big/dom to the path.
Tony.
Arthur
05-07-2001, 08:00 AM
That page is outdated. Since the upgrade to PHP4 on all servers that doesn't work.
See; http://www.aota.net/ubb/Forum15/HTML/000647-1.html
Arthur
Terra
05-07-2001, 09:12 AM
Thanks Arthur,
I've updated that AOTA.net Tutorial Page to reflect the removal of auto '/big/dom/' path prepending...
--
Terra
sysAdmin
FutureQuest
0degree
05-07-2001, 07:46 PM
Well, I tried to change the path to include the "/big/dom/" and also tried using relative paths but I still get the same results.[nbsp][nbsp]I guess something else might be wrong but for 2 days now, I still can't find the problem. :(
Tony.
PaulKroll
05-08-2001, 12:20 AM
Think you're missing semicolons at the end of your commands:
<? include "/xdomain/www/inc/header.php"; ?>
http://www.php.net
0degree
05-08-2001, 07:26 AM
Appearently that's either not the problem or it is only part of the problem.[nbsp][nbsp]Eitherway, thanks![nbsp][nbsp]Any other suggestions?
<EDIT>[nbsp][nbsp]Do I need to encolse the whole HTML code in index.php with "<? ?>" or anything else?
</EDIT>
Tony.
[This message has been edited by 0degree (edited 05-08-01@06:29 am)]
jimbo
05-08-2001, 07:47 AM
I don't know what's in your header and footer files, but if need be are you escaping your characters?
Like if you send HTML to the browser via the print command, you are doing it like this: print("<font size=\"2\">blah blah</font>");
I'm not sure if a parse error would be returned on the whole page, or if it would load the index.php page, but wouldn't load the included files due to parse errors.
Would you mind posting your code?[nbsp][nbsp]Trained eyes know what to look for :).
-jim
Terra
05-08-2001, 07:48 AM
You really should take some time to go through the many fine tutorials on the net, e.g.:
www.devshed.com (http://www.devshed.com)
Plus countless other places that can be found at both:
www.php.net (http://www.php.net)
www.zend.com (http://www.zend.com)
Look in their 'Links' section...
You may also want to curl up with a PHP book:
WROX Publishing:[nbsp][nbsp]Beginning PHP4
is pretty good, though PHP4 is currently a moving target but nonetheless provides the foundation...
--
Terra
--Open mind, Insert knowledge--
FutureQuest
0degree
05-08-2001, 08:10 AM
Here is the code for header.php:
<?
print "
<div align="center">
[nbsp][nbsp]<center>
[nbsp][nbsp]<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber1">
[nbsp][nbsp][nbsp][nbsp]<tr>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<td width="50%" bgcolor="#63659C">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<p align="left">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<a href="http://www.0degree.com/100avenue">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<img border="0" src="../images/test6_header.gif" width="560" height="79"></a></td>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<td width="50%" bgcolor="#63659C" valign="top" nowrap>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<p align="right" style="margin-top: 0; margin-bottom: 0">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<font size="2" color="#FFFFFF">
print(<STRONG>date</STRONG>("1 F d, Y"));
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]</font>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]</td>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]</tr>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<tr>
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<td width="100%" bgcolor="#63659C" colspan="2">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<p align="right" style="margin-top: 0; margin-bottom: 0">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<font size="1" color="#FFFFFF">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<a href="../dn/index.php">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<font color="#FFFFFF">Domain Names</font></a> | <a href="/wd/index.php">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<font color="#FFFFFF">Web Design</font></a> |
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<a href="../wh/index.php">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<font color="#FFFFFF">Web Hosting</font></a> |
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<a href="../gd/index.php">
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]<font color="#FFFFFF">Graphic Design</font></a></font></td>
[nbsp][nbsp][nbsp][nbsp]</tr>
[nbsp][nbsp]</table>
[nbsp][nbsp]</center>
</div> "
?>
Terra:[nbsp][nbsp]Although I have visited lots of these site, you did mention one that I didn't.[nbsp][nbsp]Thanks everyone.
Tony.
jimbo
05-08-2001, 08:58 AM
As I suspected, you didn't escape your "'s.[nbsp][nbsp]Since there is nothing on that page that you need PHP for, you can eliminate the print command and the <??>'s.[nbsp][nbsp]You can use just plain HTML.
If you want to keep it as it is, you'll need to go through and escape all your quotes - so <font color="#FF0000"> would become <font color=\"#FF0000\">.[nbsp][nbsp]That should do it for you.
And I agree with Terra - go read some books and stuff.
-jim
0degree
05-08-2001, 03:31 PM
Well thanks, that really helps.[nbsp][nbsp]Gonna work on that now :)
Tony.
vBulletin® v3.6.8, Copyright ©2000-2009, Jelsoft Enterprises Ltd.