0

I am setting up an old website on my development server and I have come across a few PHP error messages, they are as follows;

File path /php/register_company.php

Warning: include(./_mrprivate/includes/dblogin.php): failed to open stream: No such file or directory in /Sites/Martin James/_mrprivate/includes/dbaccess.php on line 29

Warning: include(): Failed opening './_mrprivate/includes/dblogin.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /Sites/Martin James/_mrprivate/includes/dbaccess.php on line 29

Warning: include(./_mrprivate/includes/dbapplogin.php): failed to open stream: No such file or directory in /Sites/Martin James/_mrprivate/includes/dbaccess.php on line 30

Warning: include(): Failed opening './_mrprivate/includes/dbapplogin.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /Sites/Martin James/_mrprivate/includes/dbaccess.php on line 30

I have played with the file paths but the error message have not changed in the slightest!

Charles
  • 50,943
  • 13
  • 104
  • 142
Brad Fletcher
  • 3,547
  • 3
  • 27
  • 42
  • 2
    What is your question? Is there anything not clear with the error messages you posted? I also can recommend our error reference which often has some cool tips on common errors: [Reference - What does this error mean in PHP?](http://stackoverflow.com/q/12769982/367456) – hakre Jan 07 '13 at 11:46
  • 1
    Where (what path) is the main PHP file that is including those files? – Pekka Jan 07 '13 at 11:47
  • /php/register_company.php – Brad Fletcher Jan 07 '13 at 11:50
  • Write your root path for an acceptable, or otherwise use full path with no `../`, read about `$_SERVER['DOCUMENT_ROOT']` and understand concepts of `php.net/getcwd`... – Davit Jan 07 '13 at 11:51
  • @BradHouston: Just a hint: having the dot `.` in the include path is normally not recommended. I did have it in the past but since I switched to the magic constants some years ago, I never needed it any longer. It's a burden to have in the include-path because PHP will look in many places if it's in there and it's normally not needed (can be a performance drain as well). – hakre Jan 07 '13 at 12:43

3 Answers3

2

Warning: include(./_mrprivate/includes/dblogin.php): failed to open stream: No such file or directory in /Sites/Martin James/_mrprivate/includes/dbaccess.php on line 29

Your code is trying to include

/Sites/Martin James/_mrprivate/includes/./_mrprivate/includes/dblogin.php

But I suspect you really want to include

/Sites/Martin James/_mrprivate/includes/dblogin.php

Don't change your include_path, either use the correct relative path (i.e. relative to the file containing the include/require directive) or an absolute path.

symcbean
  • 47,736
  • 6
  • 59
  • 94
1

I assume you have code like this:

include('./_mrprivate/includes/dblogin.php')

With your configured include path:

include_path='.:/usr/local/php5/lib/php'

You would not need to add the . in front anyway. However as this is often a cause of problems, it is way better to relate to the magic constants __FILE__ and (PHP 5.3+) __DIR__:

include(dirname(__FILE__) . '/_mrprivate/includes/dblogin.php');
hakre
  • 193,403
  • 52
  • 435
  • 836
  • Don't know exactly, but as far as I remember the leading `.` will make PHP ignoring the include path, because in fact it explicitly says "from _here_". – KingCrunch Jan 07 '13 at 12:18
  • @KingCrunch: You remember right, I just verified what you said is correct because I wanted to know as well for sure. However that is only for `./`, not for `../` and not for `/` and not for `/./` (which looks like a sneaky secret move here). We should probably create a question for that with an answer. – hakre Jan 07 '13 at 13:02
  • Starting with a `/` usually means "Filesystem root" anyway :p But this shouldn't use the include neither, because ... yeah, it is bound to the filesystem root. I guess the "secret" is, that the include path only covers "really relative" paths, whereas `.` reflects the current working directory (which is "kind of" absolut) and `/` the root (which is really absolute). – KingCrunch Jan 07 '13 at 13:55
  • Yes but the root is not taken into account actually, so writing `file.php` or `/file.php` will make PHP look into the include-path. Only writing `./file.php` won't. – hakre Jan 07 '13 at 14:58
  • Just tested it, it is not true: Actually the file is `/usr/share/peclcmd.php` and `include 'peclcmd.php';` works, but `include '/peclcmd.php';` fails. Test from within interactive shell (`php -a`) with standard include path on ubuntu `.:/usr/share/php:/usr/share/pear`. Also imo everything else would be confusing anyway ;) Especially because everything starting with `/` is _the_ absolute path of all absolute paths :D – KingCrunch Jan 07 '13 at 19:08
0

Change the site name in database.. i'm not sure but it may be help you