Jump to content

Including a file of root directory from subdomain


pracasify

Recommended Posts

Suppose, i have created a sub.domain.com and i want to include a file 'config.php' from root directory i.e domain.com . While i tried include("../config.php"); i wasn't successful. Anyone can help me please??

I need the solution very urgently, so please help me soon.

pracasify@yahoo.com

facebook.com/agptj

Link to comment
Share on other sites

assuming that your subdomain's root folder is in the main root folder of your site, and config.php is also in the main root folder of your site, using ("../config.php") should work. What is your file structure like? What page is the include statement written in? Where is said page located?

Link to comment
Share on other sites

Friend, when i click on public_html folder the files are listed like this :

public_html

  - config.php

  - sub (folder)

      - index.php

 

here,

index.php contains;

 

<?php

  include("../config.php");

?>

 

Now, when i enter url, sub.domain.com ... i can see the error message that php cannot find the steam file or directory!  :-[

 

Link to comment
Share on other sites

hmm, can you post the code you used with absolute pathing? Maybe you did something wrong with the absolute pathing.

 

Does index.php only contain that 1 include statement, or is their more?

 

Beyond some simple error, I really can't see why it wouldn't be able to find config.php. Perhaps you should open a ticket with your hosting provider

Link to comment
Share on other sites

i logged in to cpanel, then clicked on subdomain and then gave new subdomain name.... to get my subdomain!!

 

i am so surprised that same code is running on my next website!!

i think that is problem of hosting or something else...!!!

when i tried that on my another website, the code was running successfully!!

Link to comment
Share on other sites

i logged in to cpanel, then clicked on subdomain and then gave new subdomain name.... to get my subdomain!!

 

i am so surprised that same code is running on my next website!!

i think that is problem of hosting or something else...!!!

when i tried that on my another website, the code was running successfully!!

 

can you please step back for a moment, clear your mind, pretend that you are someone else who doesn't know you or your situation, read what you just wrote, and try to determine if you could possibly solve this problem with the information you just gave? "I clicked buttons and it gave me a subdomain name" tells me...what?

Link to comment
Share on other sites

Sounds like you messed up the sub domain creation to me

 

Simple example

file: /public_html/main_domain.php

<?php
$data = "I am HERE";

 

URL: http://www.madtechiesupport.com/Test_domain.php

file: /public_html/Test_domain.php

<?php
include "main_domain.php";
echo $data;

 

URL:  http://subdomain.madtechiesupport.com/Test_domain2.php

file: /public_html/subdomain/Test_domain2.php

<?php
include "../main_domain.php";
echo $data;

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.