Jump to content
Killersites Forums

Trying to include index.php thats in another folder


jp612
 Share

Recommended Posts

I recently shifted a ZenCart site to a godaddy shared hosting server. However it requires me to put the whole site inside a their html folder. However I want to put my ZenCart Folder called "zc-gj" into there with all the stuff inside. But of course it doesnt find the index.php file thats in zc-gj folder.

 

So i thought I would create a index.php in the html folder and write:

<?php
include("zc-gj/index.php");
?>

 

but all it does is give a blank screen I've tried it on my localhost and it also gives a blank screen there. I have also tried chdir,require & chroot functions but they all give a blank screen.

 

why doesn't this work?

Link to comment
Share on other sites

A blank screen might indicate some sort of error...You might want to try

 

<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);

include("zc-gj/index.php");
?>

 

Just in case there are errors you don't know about that aren't displaying since you have error reporting turned off.

 

Besides this specific include issue, is ZenCart working properly? Can you go to http://www.yoursite.com/zc-gj/index.php and the site functions properly?

Link to comment
Share on other sites

No errors I have already given that a go.

 

when i go to www.gamecat.co.nz/zc-gj it works fine.

 

Its not even working on my local host when i simulate the situation. right now on godaddy it gives an error which i have already fixed. But godaddy hasnt registred the changes again even though i have cleared cache etc. I know that because it creates the same error even if i change the include code to echo "hello"; code it still gives the function include fail error which i have actually fixed. But on the local host it gives a blank screen now and i have all error reporting on.

Link to comment
Share on other sites

The more I think about this, the more I think it's probably a path issue. ZenCart probably has to include certain files in order for it to work properly, and you using an include changes the path.

 

For example, say your ZenCart index.php file within the "zc-gj" folder includes "fileX.php". It assumes that "fileX.php" is in the same folder as the ZenCart index file. If you include the ZenCart index within a different file, outside of the "zc-gj" folder, that include to "fileX.php" no longer works -- it would need to be "zc-gj/fileX.php."

 

Basically, I don't think you'll be able to use an include since all the file paths will have to change (unless there is a way to set those paths within the ZenCart config; I haven't personally worked with ZenCart yet.)

 

If you have to keep this file structure, you may need to use PHP's header() function to redirect users that try to access gamecat.co.nz automatically to gamecat.co.nz/zc-gj/, rather than using an include.

Link to comment
Share on other sites

Yeah I was afraid that may be the case. although the chdir function didnt work and i used:

 

chdir("zc-gj/");

 

I have never used that function before so i was interested to see how it works.

 

Does using a header or any re-direct function that redirects to the zc-gj folder slow down the loading time of the site? The whole thing I'm trying to do seems a bit inefficient.

Link to comment
Share on other sites

Does using a header or any re-direct function that redirects to the zc-gj folder slow down the loading time of the site? The whole thing I'm trying to do seems a bit inefficient.

I wouldn't think so. The user will only access the main index page once, and then be redirected. For the rest of the time on the site, they will be accessing files within the /zc-gj/ folder.

 

...to be honest though, I really don't see the need for the /zc-gj/ folder in the first place. If you do want to do this, make sure it's necessary. :)

Link to comment
Share on other sites

Yeah I think your right. I just like to keep my localhost similar to my production server. oh well the header function does the job well. :)

 

However since alot of my config files in zencart are different to the localhost files I wonder how i will keep them in sync. I have always used dreamweaver to keep my sites in sync over ftp.

 

But now i need to exclude some files from synchronization. I also dont want to have to manually backup and dump the database all the time. Is there something that can help me with this??

Link to comment
Share on other sites

Getting a blank white page may indicated that you haven't changed your config file to reflect the new host's path. Not sure about Zencart but the php (and asp) programs I've used have a config file that has the default file path. Changing that to match whatever the host requires should normally fix the problem without editing a whole bunch of files.

 

So if your host path is normally something like //home/username/html/ then you would change it to //home/username/html/zc-gj/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...