Deaddog Posted July 26, 2015 Share Posted July 26, 2015 I don't understand what is going on. The CMS site works fine on local server, but when on the live site the following error occurs: Warning: require(classes/Page.php) [function.require]: failed to open stream: No such file or directory in /home/folder_name/public_html/51/includes/utilities.inc.php on line 4Warning: require(classes/Page.php) [function.require]: failed to open stream: No such file or directory in /home/folder_name/public_html/51/includes/utilities.inc.php on line 4Fatal error: require() [function.require]: Failed opening required 'classes/Page.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/folder_name/public_html/51/includes/utilities.inc.php on line 4 It seems like for some reason the Page class is not loaded. It's probably something simple and obvious, but I don't see it. Any suggestions? The utilities file code is straight from the book and php version is 5.3.29: : <?php #utilities.inc.php - Script 9.3 //Define a function that will autoload the classes: function class_loader($class){ require('classes/'.$class.'.php'); } spl_autoload_register('class_loader'); //Start the session session_start(); //Check for a user in the session. $user = (isset($_SESSION['user'])) ? $_SESSION['user'] : null; //Create the database connection as a PDO object. try { $pdo = new PDO('mysql:dbname=xxx;host=localhost','xxx','xxx'); //Catch any PDO exceptions. } catch (PDOException $e){ $pageTitle = 'Error'; include('includes/header.inc.php'); include('views/error.html'); include('includes/footer.inc.php'); exit(); } Link to comment Share on other sites More sharing options...
Deaddog Posted July 26, 2015 Author Share Posted July 26, 2015 The answer to this is simple: Took the dog for a walk, came home and re-read through chapter 8, the part where it says "Note that this does assume that the classes and class files use the same exact names( minus the extensions)." So I just changed the file classes/page.php to classes/Page.php. Such details. Strange that it worked fine on local machine with the lowercase page.php, but not on the live server. Problem solved. Link to comment Share on other sites More sharing options...
Larry Posted July 27, 2015 Share Posted July 27, 2015 Kudos for figuring it out and thanks for sharing the solution! Also, the main thing is to interrupt computer work with dog walking and other mindless things! To clarify the local vs. live server issue, there's probably a case sensitivity difference in terms of the file system (i.e., your local machine is case insensitive on the file system but your server is case sensitive). Link to comment Share on other sites More sharing options...
Recommended Posts