I am confused...........

I have made a project . No problem in localhost but whenever I try to execute in my domain server it shows :

Warning: include_once(body/login/logIn.php) [function.include-once]: failed to open stream: No such file or directory in /mounted-storage/home36c/sub003/sc29343-BHKZ/progekt.com.utpal/helora/body.php on line 68

You can check :

I have used code in my project :

define("BODY",'body/');
define("LOGIN",BODY.'login/');

@$action=trim($_REQUEST['action']);
@$script=trim($_REQUEST['script']);

if(strcmp($action,"admin")==0){
	switch($script){
	
		case 'login':include_once LOGIN."logIn.php";
			break;	
}
}

I have set all of my files 777 permissions. But no output.
Can you fix it?????

Dani AI

Generated

Several replies already hit the usual suspects: filename case, permissions and relative paths (noted by , , and ), and correctly pushed using absolute paths. Since reported the actual problem related to session usage, the checklist below ties those threads together and shows safe, reproducible steps to diagnose an include failure on a hosted Linux server.

A small diagnostic snippet placed in the script that performs the include will show exactly what PHP is trying to open and why it fails:

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

$target = __DIR__ . '/body/login/logIn.php';
var_dump(
  'cwd' => getcwd(),
  '__DIR__' => __DIR__,
  'target' => $target,
  'exists' => file_exists($target),
  'readable' => is_readable($target),
  'include_path' => get_include_path()
);

if (file_exists($target) && is_readable($target)) {
  include_once $target;
} else {
  error_log("Include failed: $target");
}

Practical checks (based on thread feedback and the later session comment):

  • Use absolute paths (DIR or realpath) to avoid cwd/include_path ambiguity.
  • Remove the error-suppression operator (@) so PHP will report the real warning.
  • If sessions are involved, ensure session_start() runs before output, session.save_path is writable, and session handling code does not call chdir() or alter include_path.
  • Inspect phpinfo(), Apache/PHP error logs, and any open_basedir or suPHP/SELinux restrictions.
  • Avoid 0777; prefer correct ownership (webserver user) with 0755 for directories and 0644 for files.

If the snippet reports the correct absolute path but is_readable() is false, address ownership/SELinux/open_basedir. If it shows a different cwd or path, convert includes to absolute paths as shown above.

Recommended Answers

All 7 Replies

Does this file exist?

/mounted-storage/home36c/sub003/sc29343-BHKZ/progekt.com.utpal/helora/login/logIn.php

Note the filename case logIn.php

Yes, this file exists (I have used logIn.php)

Member Avatar for Member #120589

This looks like an extremely convoluted method of running a login script.

define("BODY",'body/');
define("LOGIN",BODY.'login/');
 
@$action=trim($_REQUEST['action']);
@$script=trim($_REQUEST['script']);
 
if(strcmp($action,"admin")==0){
	switch($script){
 
		case 'login':include_once LOGIN."logIn.php";
			break;	
}
}

You can replace the defines with a var;

$phproot = $_SERVER['DOCUMENT_ROOT'];
 ...
case 'login':
 include_once "$phproot/logIn.php";
 break;
...

if there's an error test:

if(file_exists("$phproot/logIn.php")){
  "yes!";
}else{
  "dawg down chew tabbacee";
}

this error clearly says the file did not exist, you file logIn.php does not exist, try re checking your file on it's directory body/login/

Thanks ... That file was there but I have mistaken in my code with session use. Sorry about that. That running in my localhost without no problem but problem in web server.

Did u set file permissions for the project folder?
If your server is a Linux server definitely you have to set the file permission.

Linux server treat case-sensitive. logIn.php and login.php are different whether they're same file on Windows server. Check your filename.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.