0

I have a tiny test cms. These are the directories:

admin
--css
----admin.css
--js
--tinymce
--index.php
--functions.php
--logout.php
--blogadmin.php
--imagesadmin.php
--videosadmin.php
--connectadmin.php
--maincontentadmin.php
--settingsadmin.php
css
--cssimages
--mainstyle.css
js
images
plugins
--blog.php
--images.php
--videos.php
--connect.php
uploads
config.php
index.php
mysql.php

The admin/functions.php needs the mysql.php.

require("../mysql.php");

It works.

The plugins/connect.php needs the admin/functions.php

require("../admin/functions.php");

The plugins/connect.php is included in the index.php And the files in the admin folder using the functions.php too.

It doesn't work. Why?

Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64
darksoul90
  • 145
  • 2
  • 16

2 Answers2

0

Because you are including plugins/connect.php from index.php, the code from connect.php is being run inside index.php. So the path you are using needs to be admin/functions.php, which is relative to index.php.

If this isn't an option for you, because plugins/connect.php gets included from multiple places, you should consider using absolute paths include your include. For example, use C:\wamp\www\cms\admin\functions.php instead.

dpk2442
  • 701
  • 3
  • 8
  • It's ok on localhost, but I won't use it on localhost forever – darksoul90 Apr 10 '14 at 17:44
  • You can still use the absolute paths on another machine. As long as you have to proper path, you should be able to include with just about any host. – dpk2442 Apr 10 '14 at 17:59
  • How can I check the root directory if somebody installs my cms? – darksoul90 Apr 10 '14 at 18:01
  • If you make a php script, put `` in it, and access it from a browser, it should print out the full path to the file you are accessing. That should help you figure out the absolute path on the server. – dpk2442 Apr 10 '14 at 19:45
0

The only solution I found is to copy the mysql.php in the admin folder and change this line:

require("../mysql.php");

in the functions.php to this:

require("mysql.php");

I don't like it, but it works.

darksoul90
  • 145
  • 2
  • 16