Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
Featured Web Site Template

Hundreds More at Free Site Templates.com!

Web Site Partners
Sponsored Links
Jet City Software
 
Whos Here ?
Reflects user activity within the last 5 minutes
Moderator(s): Prowler, jcokos
Member Message

SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-May-29 15:09
Edit Message Delete Message Reply to this message

I've posted this over at WMW, but the suggestions so far have not worked - not that the SUGGESTIONS are necessarily bad - it could be I don't know what I'm doing and I'm missing something simple...anyway, figured I'd try here, too, just in case...

SUMMARY:

How do I use includes in my pages residing in the subdomain of my main site? Naturally the includes work fine on the main domain, but I cannot figure out how to get includes to work for the subdomain pages - please read on for more details which explain what I have already tried.

THE FULL MAGILLA:

Now, I'm posting this in this section because I'm by no means a web developer, programmer, sysadmin, etc.

I do have a couple of small, active sites which hum along, and I've learned a lot in building them, but this is my first foray into the world of subdomains. *shudder*

My problem is this:

I am trying to use php includes in the subdomain pages - but cannot get them to show on the live page. sad

Some back-ground:

1 - I'm on a virtual dedicated server, so I have full access to "my" server.
2 - Obviously it's running php (Linux/Apache - I never know how to properly say this like "It runs Windows" ) - (I am a dumbass, I know)
3 - All includes work fine on the main website

Now, I have been at this for about 6 hours so far today and here's a run-down on what I've tried (and what has failed). I'll try to do this justice as I know a wrong character or misplaced space can cause things to go awry... (f-ing .htaccess files! I love them now, but hated them for about 3 hours one cold, dreary Sunday... LOL)

The main website is structured as such:

http://www.domain.com/file-name.html

Includes reside as:

http://www.domain.com/includes/nav.php

Images, same dealio...

Now, on the main domain, I use the following code to bring in the includes:

<?php include('includes/test_header.php');?>


Brings it in on a "relative path", if I'm using the correct terminology there.

Now, dropping this code into the test page (http://subdomain.domain.com/template-page.html) I have in the subdomain (http://subdomain.domain.com/) nets me squat.

I have the following folders created in the subdomain:

/includes/
/images/

Now, the confusing part for me is that I do actually have the php files I want included inside this /includes/ folder in the subdomain. If I type the direct path for the file into the address bar, it shows up nicely.

Images are pulled into the subdomain test page properly (from the /images/ folder in the subdomain).

I have tried the following combinations of include code and more - all of which have failed to be successful (the actual file I'm testing for is named "sc_header.php" ):

<?php include("subdomain.domain.com/includes/sc_header.php" );?> (quotes, no "http://" )

<?php include("http://subdomain.domain.com/includes/sc_header.php" );?> (quotes & "http://" )

<?php include('subdomain.domain.com/includes/sc_header.php' );?> (apostrophies, no "http://" )

<?php include('http://subdomain.domain.com/includes/sc_header.php' );?> (apostrophies & "http://" )

<?php include("http://www.domain.com/includes/sc_header.php" );?> (tried calling from the main domain's include folder - no joy - tried this with quotes & apostrophies, with and without the "http://" )

<?php include('domain.com/subdomains/nameofsubdomain/httpdocs/includes/sc_header.php' );?> (this one with quotes and apostrophies and every permutation of inclusion or removal of listed items in the path - with and without "httpdocs", for example.

Heck, I even just tried dropping the file into the root of the subdomain and calling it from there - again, zip.

I've searched threads here, at php.net and generally through Google today - nothing helped point me in a direction that worked. I did find some ideas of things I hadn't tried, but when I did try them, nada.

I came across some references to "cgi-bins", but not being a programmer, etc., I have no clue what they are, how to set them up or how to use them. I'm hoping for a simple solution to this problem, rather than a lessons in yet another new item to learn.

So, there we go folks - I'll throw myself at your mercy.

As I mentioned near the beginning of this post - I am NOT a web developer, programmer or sysadmin - it's been a long, frustrating journey to learn what I know on my own, and I am still firmly encamped in my "Noob Webmaster" status.

I'd appreciate any partical suggestions and idea that are directly applicable to solving this problem.

I clearly am missing something in my understanding of what works with subdomains... sad

**Please Note: in the code smaples above, I have added a space between " & ) or ' & ) as this forum makes them appears as winking smileys... In the actual coding on the live webspage those spaces do not exist.**

[ Message was edited by: SportsGuy 05/29/2006 07:23 am ]





Dinkar
Staff
Joined: Aug 12, 2001
# Posts: 4391

View the profile for Dinkar Send Dinkar a private message

Posted: 2006-May-29 16:29
Edit Message Delete Message Reply to this message

If your file structure is like this:

/ (Web Root)
/includes/
/includes/test_header.php
/subdomain/
/subdomain/index.php

Add the following code to /subdomain/index.php to include /includes/test_header.php file.




Code: [copy]








SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-May-29 17:04
Edit Message Delete Message Reply to this message

Thanks Dinkar - tried it and it didn't work. sad Even added "php" before "include" and tried that - no go. sad

Just to add some clarity on the file structure I'm running, it's like this for the main domain:

http://www.domain.com/includes/filename.php

For the subdomain it's a mirror, basically, just stacked in the subdomain "area" on the server:

http://subdomain.domain.com/includes/filename.php

The reason I'm positng this is I noticed you had the list as:

/subdomain/index.html , etc.

Did that mean you understood the file structure to be:

http://www.domain.com/subdomain/includes/filename.php?

...or does that point even matter...?

...in essence, are these two items the same thing?

http://www.domain.com/subdomain/includes/filename.php
http://subdomain.domain.com/includes/filename.php



david68
Joined: May 16, 2005
# Posts: 144

View the profile for david68 Send david68 a private message

Posted: 2006-May-29 17:18
Edit Message Delete Message Reply to this message

Is the server set up to not allow files to be used by other websites (like disabling hotlinking) - although is a SUBdomain considered a different site? Just a thought.

Seems to me if you type the path/filename in your browser, run it, copy that - it should work.





SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-May-29 18:40
Edit Message Delete Message Reply to this message

Is the server set up to not allow files to be used by other websites (like disabling hotlinking) - although is a SUBdomain considered a different site? Just a thought.

Seems to me if you type the path/filename in your browser, run it, copy that - it should work.


Interesting you should bring this up. This is NOT the case right now, but I was going to edit the .htaccess file later this month to bump MySpace off for just such a thing. wink

At WMW, one poster suggested it *might* be the redirect I have for the non-www to www thing. Can't see it myself, though, as it specifies the actuall non-www version to be redirected AND, the page loads fine - it's the include that's screwy. sad



Dinkar
Staff
Joined: Aug 12, 2001
# Posts: 4391

View the profile for Dinkar Send Dinkar a private message

Posted: 2006-May-29 19:28
Edit Message Delete Message Reply to this message

SportsGuy, don't see your file structure from 'web' point of view i.e. domain.com/filename or subdomain.domain.com/filename

Use file manager or FTP software to see actual file structure.

On root directory you may find 'public_html' directory and 'www' shortcut to that directory. I called this as 'web root'. Use your file manager located in your hosting control panel or use some ftp software to find where your subdomain directory is located. Generally it is located in public_html. Give the correct 'server path' for include file. It's working on my server so it should work on yours too.

I have following file permissions:

public_html 750
Other folders in public_html 755
include file 0644
php file that uses include file 0644

HTH.



SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-May-29 19:45
Edit Message Delete Message Reply to this message

Confusing as all-get-out Dinkar, but that's just because it's my first time really paying attention to the file structure in this manner. smile

I'll take a look through the server interface and the ftp interface I use sometimes to see if I can fill in the blanks I missed.

Might be called different things on my server, but regardless, this information seems like a good place to start looking.

Thanks again,

Duane



SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-May-29 21:04
Edit Message Delete Message Reply to this message

Well, I tried every combo I could think of using the path shown to me in my ftp client. Nothing worked. sad

I'm seriously bummed about this now.

Here's the path as laid out when using the IE as the FTP tool (it's the same basic path I see when trolling through things in my server interface - the only difference I see is the ftp portion, which I'd expect using an ftp interface):

ftp://domain.com/subdomains/name-of-subdomain/httpdocs/includes/

I swapped the ftp for http, then tried it without anything - just domain.com, etc., etc... With the www and without. Obviously after the last / I have the file name in there (sc_header.php) for all permutations.

I even changed the view permissions on the "httpdocs" folder everything sits inside to ensure "ALL" was selected in the "View" list. All other file sin the path were already set this way.

Man, this is one huge PITA... sad



Dinkar
Staff
Joined: Aug 12, 2001
# Posts: 4391

View the profile for Dinkar Send Dinkar a private message

Posted: 2006-May-29 22:12
Edit Message Delete Message Reply to this message

PM me your hosting username and password if you are interested.



Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1795

View the profile for Prowler Send Prowler a private message

Posted: 2006-May-30 09:53
Edit Message Delete Message Reply to this message

Looks like I arrived a bit late on the scene. One caveat: sending server passwords by PM is not recommended.


Let's get down to the meat of the matter here.

As I am a little short of time, I reproduce what I have understood from the long message here.

1. You want to include a file
2. And the file is somewhere in the includes directory.

When it comes to servers, it is prudent to do one thing: Don't assume something unless it is proved.

You call up the included file from your browser like so:

http://your_domain.com/includes/included.php

If you can see the file, then copy and paste the same URL in your include statement. If you have enabled log_errors = On in your php.ini, you could see where the error is.

If the above step fails for any reason, try and include another file with some simple HTML statements from the same directory.

I suggest that you enable the log_errors = On in your php.ini temporarily to check the source of error.





SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-May-31 15:59
Edit Message Delete Message Reply to this message

I suggest that you enable the log_errors = On in your php.ini temporarily to check the source of error.


I'm all for it...

Where the heck do I look t find that file and what/how do I change it?

I just looked around on my server and saw squat even remotely resembling this php.ini file. sad

To cover a couple other points:

1 - if I type the direct path to the include file into my address bar, it shows perfectly.
2 - I've built the test page to call an image from the image folder located in the subdomain area - works perfectly, too.

Still freakin' stumped...





Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1795

View the profile for Prowler Send Prowler a private message

Posted: 2006-Jun-01 05:14
Edit Message Delete Message Reply to this message

Ok. Stick this in a file called test.php and view this in your browser:

<? phpinfo();

?>
That will show you a nicely formatted details about your server and its PHP configuration.

Look for this :
Configuration File (php.ini) Path :

Note the path your php.ini's location and open this file in a text editor. Make sure you issue a command like the following ( to make a backup of the original file)
cp php.ini php.ini.orig

I assume that you have a SSH access to do this. You will not be normally permitted to navigate into the 'internal' regions of the server by FTP.

From the Shell prompt you can type vi php.ini to open the text editor with the php.ini

Scroll down to the area where you have an entry like so:
; - log_errors = On
Remove the ; and you are set to log the errors.

whilst at it you might want to check the following out:

safe_mode = Off
safe_mode_include_dir =

After your changes, save the file and restart apache. I know it all sounds a little complicated for the uninitiated, but if you follow the directions, you can do it.

Alternatively you can ask the server admin to set the parameters as per your direction. All managed servers still have a sysadmin who is responsible for their upkeep.




Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1795

View the profile for Prowler Send Prowler a private message

Posted: 2006-Jun-01 05:29
Edit Message Delete Message Reply to this message

I re read the message and it is obvious that your server is configured to be SAFE_MODE-safe. It is sometimes very restrictive.

You will find some information regarding this here: [link]

Sometimes, your server might be looking for the include file in the wrong path.

You can guide 'her' to the right path like here:
include $_SERVER['DOCUMENT_ROOT'].'/include.php';





SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-Jun-01 15:34
Edit Message Delete Message Reply to this message

Thanks prowler - yet more questions:

1 -
include $_SERVER['DOCUMENT_ROOT'].'/include.php';


Do I replace "SERVER" and "DOCUMENT ROOT" with anything, or do they stay as typed above?

2 - I am now seeing that phpinfo stuff - VERY informative, I must say - not that I understand much of it, but still.

3 - I went looking for the php.ini file where the phpinfo doc suggests it resides - cannot see it anywhere in that folder. sad

4 - Tried the "include path" outlined for the website in the template page, nada - hell, I relocated the include item to the normal (domain.com) "includes" folder and told the doc the full path ot it, and tried the abbreviated path, too - still nothing.

EX - I tried:

http://www.domain.com/includes/sc_header.php as the path suggested in the phpinfo doc is .:/domain.com/httpdocs/includes

...and...

/includes/sc_header.php

All of it a big fat nothing.

WTF is goig on here that I cannot get a simple include to work in a subdomain? Images will call in fine form the "images" folder in the subdomain, but includes will not...

[ Message was edited by: SportsGuy 06/01/2006 08:38 am ]





SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-Jun-01 16:40
Edit Message Delete Message Reply to this message

Do I replace "SERVER" and "DOCUMENT ROOT" with anything, or do they stay as typed above?


ANSWER - I think I do - see below:

Found the following items in that phpinfo page:

1 - server = www.domain.com - replaced SERVER with that
2 - document root = /var/www/vhosts/domain.com/httpdocs, so I replaces DOCUMENT_ROOT with that data.

So, my "include" code now resembles this:

<?php include(include $_www.domain.com['/var/www/vhosts/domain.com/subdomains/sports-cars/httpdocs/includes'].'/sc_header.php'; );?>


I added a space in there to make sure the smiley wouldn't appear when this is posted - right here: header.php';SPACE);?>.


...and still nothing works.

I tried adding a couple of folders into the doc_root string (domain/com/subdomains/sports-cars/ and it didn't work.

I'm beginning to think there's a setting on the server which instructs the system on how to handle subdomains only - but I have no idea - it's just a guess to try to "pin down" the problem. sad



Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1795

View the profile for Prowler Send Prowler a private message

Posted: 2006-Jun-02 09:03
Edit Message Delete Message Reply to this message

$_SERVER['DOCUMENT_ROOT'] is a server environment variable. You don't substitute it with anything else. The server will fill in the details when it runs it.

Your problem is really a matter of configuration. Hardly a cause to celebrate when you can't fix the issue.

Now on to your questions:


>> 2 - I am now seeing that phpinfo stuff - VERY informative, I must say - not that I understand much of it, but still.

Remember to delete this file after you are done with the testing.


>> 3 - I went looking for the php.ini file where the phpinfo doc suggests it resides - cannot see it anywhere in that folder.
The whole thing hinges on your modifying this file. I would assume that you had looked for this file from a Shell prompt. If you can send me this file, I will set this in a development server and set the parameters to make your includes work and send it back.






SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-Jun-02 13:03
Edit Message Delete Message Reply to this message

OK

Problem 1 - I shouldn't have messed with the SERVER/DOCUMENT_ROOT hitng. sad I shall change THAT poste haste...

Problem 2 - what's a "shell"? I log onto the server and use Plesk as the interface I work through - beyond that, I have no idea...unfortunately.

I suspect we're getting to the "He has no right being a webmaster" stage about now... sad



Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1795

View the profile for Prowler Send Prowler a private message

Posted: 2006-Jun-02 13:27
Edit Message Delete Message Reply to this message

No way. I agree messing with the configuration settings is a bit daunting. But with patience and a little guidance, it can be tackled.

Look for Shell Access in Your Plesk. I don't have a Plesk enabled server at the moment. It will take you to something which looks like the MS DOS prompt. That gives you complete access to the server albeit in a cryptic fashion.

Download Putty from here : [link]

It is a small Windows SSH client and enter your server IP address/domain name and set the protocol to SSH in the radio button. It will open a DOS like window and ask for user name and password. You might have to enable this SSH from your Plesk control panel.
Once there, you can navigate to the directory pointed out by your PHP information page. You will need to know a bit of unix/linux command to list the directory etc. smile





SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600

View the profile for SportsGuy Send SportsGuy a private message

Posted: 2006-Jun-09 00:13
Edit Message Delete Message Reply to this message

OK, so I found the shell access. Opened it, the java applet started to load, then I get a bunch of errors on the screen... sad

I'm really getting frustrated with this freaking problem - it's been weeks and every single thing which was suggested both here and at WMW I've tried - without success. Well, I've tried what I could, learned about things I didn't understand, and tried again - and failed again and again.

Should this not just be as simple as using includes in the html files for the main domain?

I'd like to simply give up, walk away from this idea and just throw everything I want to create into a new FOLDER in the mian domain. Trouble is, it deserves to be subdomained - it's related, but distant enough to not make sense in a FOLDER. Plus, we're talking 300 - 400 new pages - pages with ads on them...

Am I the only person online who's ever encountered this freaking problem? *sigh*



Dinkar
Staff
Joined: Aug 12, 2001
# Posts: 4391

View the profile for Dinkar Send Dinkar a private message

Posted: 2006-Jun-09 01:51
Edit Message Delete Message Reply to this message

You can use an easy way. Just copy all include file in the same folder where main file (php file that has include command) exist. It should work.



You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
  1. You have not yet logged in, or registered properly as a member
  2. You are a member, but no longer have posting rights.
  3. This is a private forum, for which you do not have permissions.

If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

If you cannot find this message, click here to Re-Send it.

If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

New posts Forum is locked
© 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions