UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 9th February 2010, 05:39 PM   #1 (permalink)
paulcobb
Registered User
 
Join Date: Jan 2008
Posts: 6
Includes in root directory

I am using an include statement in a .shtml file

<!--#include virtual="folder_name/myfile.php" -->

The php file looks in a directory and loads its contents ready for use.

I am working on the development site by accessing using
http://myservername.unitedhosting.co...sitename.co.uk

The include works on this site albeit the images do not load in the root directory whereas they will in child directories.

I therefore tested the code in one of my live sites on unitedhosting servers to try to debug the problem

If the code is in a file which is in 'html' root the statement breaks the file completely.

I am guessing that it is the .php being included into a .shtml file but why does it work in child directories but not in root.

There may be a logical reason - but I'm not getting it!

Many thanks,

Paul
paulcobb is offline   Reply With Quote
Old 9th February 2010, 07:35 PM   #2 (permalink)
paulcobb
Registered User
 
Join Date: Jan 2008
Posts: 6
Actually it does not work in the child directories on the live server!
It does work when I am looking at my development version which is not available via DNS, but accessible on my UH server.
It is definitely the fact that it is a php include within a shtml file, when I change to HTM style it will load, but I need the PHP for this include.
I have this working elsewhere though - what do I need to do to configure??
paulcobb is offline   Reply With Quote
Old 13th February 2010, 11:26 AM   #3 (permalink)
Lost_Password
Registered User *****
 
Join Date: Feb 2006
Posts: 76
As you have said, it might be a problem with the type of file extension (shtml,html,php) and how the server treats each one.

But you mention that you're getting different results, depending on where the file is put. For you it works better in some locations than in others. This sort of thing tends to happen when the paths to the other files are wrong.

Some paths are 'relative' (if you move the file, it won't be able to find the other file if you don't move them to a similar location in relation to where it was before).

Analogy: If you live at No.10 to get to No.8 you just go next door. But if you move to No.20 you can't just go next door, otherwise you'll be at 18.

Some paths are 'absolute', either because you're using the exact file location such as the full domain name, path and file name OR because you're using the exact file location of your internal files.

PHP Code:
<?php 

include("/var/www/html/content_cars.html"); 

?>
Would work no matter where you called the file from.

D
__________________
Incongruent Juxtaposition (TM)
Lost_Password is offline   Reply With Quote
Old 13th February 2010, 11:37 AM   #4 (permalink)
Lost_Password
Registered User *****
 
Join Date: Feb 2006
Posts: 76
As you have said, it might be a problem with the type of file extension (shtml,html,php) and how the server treats each one.

But you mention that you're getting different results, depending on where the file is put. For you it works better in some locations than in others. This sort of thing tends to happen when the paths to the other files are wrong.

Some paths are 'relative' (if you move the file, it won't be able to find the other file if you don't move them to a similar location in relation to where it was before).

Analogy: If you live at No.10 to get to No.8 you just go next door. But if you move to No.20 you can't just go next door, otherwise you'll be at 18.

Some paths are 'absolute', either because you're using the exact file location such as the full domain name, path and file name OR because you're using the exact file location of your internal files.

PHP Code:
<?php 

include("/var/www/html/content_cars.html"); 

?>
Would work no matter where you called the file from.

D
__________________
Incongruent Juxtaposition (TM)
Lost_Password is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 06:30 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  SEO by vBSEO 3.0.0
Copyright © 1998-2009 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309