cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution

Unable to find path in my website for database class

I uploaded file with php oops. but it throwing error include(classes/DatabaseObject.class.php): failed to open stream: No such file or directory in /home/v364nw9h6v2e/public_html/altist.in/private/initialize.php on line42

 

<?php

ob_start(); // turn on output buffering

// Assign file paths to PHP constants
// __FILE__ returns the current path to this file
// dirname() returns the path to the parent directory
define("PRIVATE_PATH", dirname(__FILE__));
define("PROJECT_PATH", dirname(PRIVATE_PATH));
define("PUBLIC_PATH", PROJECT_PATH . '/public');
define("SHARED_PATH", PRIVATE_PATH . '/shared');
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
 define('SITE_ROOT', $_SERVER['HTTP_HOST']. DS . 'altist.in' );

// Assign the root URL to a PHP constant
// * Do not need to include the domain
// * Use same document root as webserver
// * Can set a hardcoded value:
// define("WWW_ROOT", '/~kevinskoglund/chain_gang/public');
// define("WWW_ROOT", '');
// * Can dynamically find everything in URL up to "/public"
$public_end = strpos($_SERVER['SCRIPT_NAME'], '/admin') + 7;
$doc_root = substr($_SERVER['SCRIPT_NAME'], 0, $public_end);
define("WWW_ROOT", $doc_root);

require_once('functions.php');
require_once('status_error_functions.php');
require_once('db_credentials.php');
require_once('database_functions.php');
require_once('validation_functions.php');

// Load class definitions manually

// -> Individually
// require_once('classes/bicycle.class.php');

// -> All classes in directory
foreach(glob('classes/*.class.php') as $file) {
require_once($file);
}

// Autoload class definitions
function my_autoload($class) {
if(preg_match('/\A\w+\Z/', $class)) {
include('classes/' . $class . '.class.php');
}
}
spl_autoload_register('my_autoload');

$database = db_connect();
DatabaseObject::set_database($database);

$session = new Session;

?>
13 REPLIES 13
Super User III
Super User III

Re: Unable to find path in my website for database class

@Satyajeet17 

1) Is the PHP you posted in the post the DatabaseObject.class.php or the initialize.php?

2) I tried to get to http://altist.in/classes/DatabaseObject.class.php and http://altist.in/private/classes/DatabaseObject.class.php

both of these gave file not found

 

So it would seem like you a missing a file on your site and that is what is causing the error

 

 



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: Unable to find path in my website for database class

Hi @PL281 this is code for initialize.php

Super User III
Super User III

Re: Unable to find path in my website for database class

@Satyajeet17 

 

As I mentioned it looks like you are missing the DatabaseObject php file and that is why it's producing the error - If it is uploaded I would double check the spelling & case (upper/lower) matches to the error message



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: Unable to find path in my website for database class

Hi @PL281  all class file in lowecase like databaseobject.class.php

 

 

[11-Jul-2019 09:01:18 UTC] PHP Warning: include(classes/DatabaseObject.class.php): failed to open stream: No such file or directory in /home/v364nw9h6v2e/public_html/altist.in/private/initialize.php on line 45
[11-Jul-2019 09:01:18 UTC] PHP Warning: include(): Failed opening 'classes/DatabaseObject.class.php' for inclusion (include_path='.:/opt/alt/php72/usr/share/pear') in /home/v364nw9h6v2e/public_html/altist.in/private/initialize.php on line 45
[11-Jul-2019 09:01:18 UTC] PHP Fatal error: Uncaught Error: Class 'DatabaseObject' not found in /home/v364nw9h6v2e/public_html/altist.in/private/initialize.php:51
Stack trace:
#0 /home/v364nw9h6v2e/public_html/altist.in/index.php(1): require_once()
#1 {main}
thrown in /home/v364nw9h6v2e/public_html/altist.in/private/initialize.php on line 51

Super User III
Super User III

Re: Unable to find path in my website for database class

@Satyajeet17 

 

I would try to change that to mixed case as unix/linux is case sensitive

 

You maybe able to change the line toward the end where you have database object in mixed case to lower case to fix it as well... as I said though I would change the file name to mixed case 



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: Unable to find path in my website for database class

@PL281

What should i do

Super User III
Super User III

Re: Unable to find path in my website for database class

@Satyajeet17 

 

I would suggest renaming databaseobject.class.php to DatabaseObject.class.php

 

Then your script should work



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: Unable to find path in my website for database class

@PL281 

 

I renamed but still not working

Super User III
Super User III
Solution

Re: Unable to find path in my website for database class

@Satyajeet17 

 

You did

http://altist.in/private/classes/Databaseobject.class.php

 

You need

http://altist.in/private/classes/DatabaseObject.class.php

 

The O needs to be capital as well - As mentioned unix is case sensitive so you need to make sure it matches exactly



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: Unable to find path in my website for database class

@PL281

 

Thank you it's working but is there any other way so i can use in same format as i did it previous

Super User III
Super User III

Re: Unable to find path in my website for database class

@Satyajeet17 

 

One thing to try is change the line DatabaseObject::set_database($database); to 

 

databaseobject::set_database($database);

 

That "MAY" set get it to look for the file as all lower case but I'm 100% certain on that.



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: Unable to find path in my website for database class

@PL281

 

I understand but i want it as DatabaseObject::set_database($database); and file name like databaseobject.class.php is there any function so i can use in initialize.php

 

and is there any error in this function

 

 

function my_autoload($class) {
if(preg_match('/\A\w+\Z/', $class)) {
include('classes/' . $class . '.class.php');
}
}
spl_autoload_register('my_autoload');

 

Super User III
Super User III

Re: Unable to find path in my website for database class

@Satyajeet17 

 

Unfortunately, I'm not going to be able to further debug your PHP code - The first issue was just a case issue on the file name - there maybe something else in your code that is causing it to look for the file name in mixed case or it maybe the statement I provided.

 

also without seeing all the code and just seeing one file it's it would be a very back and forth process to debug



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community