|
Posted by tom_sawyer70@yahoo.com on 04/19/07 22:01
On Apr 19, 2:41 pm, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com> wrote:
> <tom_sawye...@yahoo.com> wrote in message
>
> news:1176985902.518754.131900@p77g2000hsh.googlegroups.com...
>
>
>
> > On Apr 19, 12:04 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com>
> > wrote:
> >> I can't be sure but chances are your paths are wrong.
>
> >> Whe you do
>
> >> <?php include ("includes/nav.php"); ?>
>
> >> You are including w.r.t to the current path
>
> >> i.e.
>
> >> /srv/www/htdocs/jennifer/jennifer.php is the file and its looking for
> >> nav.php at
> >> /srv/www/htdocs/jennifer/includes/nav.php
>
> > Jon,
> > Thank you for the reply. I have tried variations on the path,
> > including trying to go right to the file with
> > /srv/www.htdocs/includes/nav.php
>
> > or
>
> >http://localhost/includes/nav.php
>
> > Neither works.
>
> > The interesting thing is even if I try a basic php command, such as to
> > echo a string, I get no error or result. However, if I do an html
> > statement, such as <p>print here</p>, it works.
>
> ok:
> not sure if this is the problem but your two php files are different:
>
> <div id="nav">
> <?php include ('nav.php'); ?>
> </div>
>
> in one you said works and
>
> <div id="nav">
> <?php include ("includes/nav.php"); ?>
> <p>
> </div>
>
> in the one that you said didn't.
>
> So it looks like an include problem. A path problem.
>
> <?php include ("/includes/nav.php"); ?>
>
> I know you said you already tried by try this again and see if it works. You
> shouldn't have to set php's includes dir for this.
>
> Try changing Index.php to
> <?php include ("/includes/nav.php"); ?>
>
> and see if it still works. IT SHOULD if / is the root. That is if when you
> browse tohttp://hostIP/Index.phpit should work and thenhttp://hostIP/Jennifer/Jennifer.php.
>
> HostIP is the ip that your appache server uses(mine doesn't work with local
> host by my LAN IP.
>
> Make sure its not actually using nav. That is, use a temporary nav.php of
> something like
> <?php echo 'FROM /INCLUDES/NAV.PHP'?>
>
> Then look at Index.php and the source and see if you can find it. I would
> strip away all the html code except is what is necessary to troubleshoot the
> code. Index.php and Jennifer.php should just contain
>
> <?php include ("/includes/nav.php"); ?>
>
> and nav.php should just contain
>
> <?php echo 'FROM /includes/nav.php'?>
>
> Then you can be sure of the results you get. It should work in both unless
> or niether. If it works from niether then your root directory isn't '/' but
> something like '/htdocs' so you'll need to change it.
>
> Your issue is that your tring to load up nav.php in jennifer.php in
>
> /srv/www/htdocs/jennifer/jennifer/includes/nav.php
>
> -jennifer.php-
> <div id="nav">
> <?php include ("includes/nav.php"); ?>
> <p>
> </div>
>
> But obviously that file doesn't exist there. You can check this easily to
> see if its the problem by copying your includes dir to the jennifer dir and
> see if everything works. If it does then either do
>
> <div id="nav">
> <?php include ("../includes/nav.php"); ?>
> <p>
> </div>
>
> or use the absolute paths above(make sure to delete jennifer/includes so you
> don't get false results).
>
> Hopefully something there helped. I would try to start from scratch. It
> seems I had the exact same issue but I got confused because I forgot to
> change all paths to absolute and so some of the relative paths were making
> it look like it didn't work... so I spend about an hour trying to figure out
> the problem and then saw I had more links that I forgot to make absolute.
> Once I did that everything worked.
>
> Jon
Jon,
ARGH (this is why I don't program for a living). I kept thinking
about the fact that no php commands were working and eventually
stumbled across my dilemna. My nav.php file was called
"jennifer.html," rather than "jennifer.php."
I thought that I could include an html file from a php statement
(above, my syntax was wrong...the jennifer.php was actually
jennifer.html) and that php would just embed the html, but the only
change I made from it "not working" to "working" is renaming the
*.html file to *.php. Ironically, a colleague also looked at the code
visually and through Dreamweaver and said that everything looked all
right. I seem to recall from some of the tutorials that including an
html file was acceptable, but maybe not...or I have a directive that
is interfering. Anyway, this is a big thorn out of my side.
I appreciate your assistance and input.
Dave
Navigation:
[Reply to this message]
|