cym0ej12 Posted May 7, 2012 Share Posted May 7, 2012 Hello, The following is my situation where I seem to get a 500 error code from the linux server: i have an 'index' file like this: <?php require("includes/config.php"); $a = $_REQUEST['a']; switch ($a) { case "home": include("frontpage/main.php"); case "user-process": include("user-process.php"); } ?> config.php is something like this: <?php require(includes/classes/session.class.php); require(includes/classes/user.class.php); require(includes/classes/db.class.php); ... ?> Now if we fall into the case "home" it works fine. Instead, if we fall into user-process it writes to the logs file Fatal Error: Class User does not exist bla bla bla. Why doesn't it exist ? every class is included in the config.php file then index.php includes first config.php ( which has all the classes) and then includes the requested page. I also have a .htaccess file which is as follows: RewriteEngine On RewriteRule ^([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7 [NC,L] which is used to access in a SEO friendly way the pages that users request. Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2012 Share Posted May 7, 2012 Why doesn't it exist ? What is the code in the includes/classes/user.class.php file (show the opening php code tags as well)? Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343792 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 http://pastebin.com/a6Fdby5m <- Users class Though i don't think there's a problem in the users class because it works on a windows apache server. and it also works if i include it again in the 'users-process.php' file. that's strange... Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343796 Share on other sites More sharing options...
batwimp Posted May 7, 2012 Share Posted May 7, 2012 This probably won't solve your immediate problem, but you need to put breaks in your switch: switch ($a) { case "home": include("frontpage/main.php"); break case "user-process": include("user-process.php"); break; } Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343797 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 there are breaks actually but i didn't copy the real code i just created it here to give an example and i forgot the brakes. thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343798 Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2012 Share Posted May 7, 2012 it also works if i include it again in the 'users-process.php' file You probably have more than one "includes/config.php" file, at different paths, and the include_path statement is causing the wrong one to be included/required. What does echoing the output from a get_include_path statement show on both your Windows and linux systems? Do you have more than one config.php file present? Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343801 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 windows: .;C:\xampp\php\PEAR linux: .:/usr/share/php:/usr/share/pear you say this might be the problem ? Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343802 Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2012 Share Posted May 7, 2012 you say this might be the problem ? Only if either the /usr/share/php or /usr/share/pear paths also contain an includes/config.php or includes/classes/user.class.php file or you have an includes path stating in the folder with your main file and you have an includes path starting in the includes folder. Since we only see the information you post, it will take seeing the actual error message (xxxxx out any part of your account name/domain you don't want to post, but leave all the syntax/paths as is) and the actual require statements in order to have a chance at helping you pinning down the actual problem. Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343811 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 Since we only see the information you post, it will take seeing the actual error message (xxxxx out any part of your account name/domain you don't want to post, but leave all the syntax/paths as is) and the actual require statements in order to have a chance at helping you pinning down the actual problem. I understand. It's not that i don't want to give information like domain name or stuff... no problems with that... the problem now seems to be bigger now since it's not writing anything in my logs file... I'm gonna check out on that and then i'm gonna post with more detailed information Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343818 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 the full error in my logs file is: [Mon May 07 22:33:28 2012] [error] [client 173.245.49.155] PHP Fatal error: Class 'User' not found in /var/www/newline/shareit/user-process.php on line 24, referer: http://newlinecode.com/shareit/homepage if you'd like to try the output on the web browser you can go to http://newlinecode.com/shareit and put whatever you like as username and password, it will produce the same error anyway Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343822 Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2012 Share Posted May 7, 2012 After your require("includes/config.php"); statement, add the following two lines of code to get a list of the actual files that have been included/required at that point and to stop execution before the fatal class not found ... error - echo '<pre>',print_r(get_included_files(),true),'</pre>'; die; Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343824 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 thanks for the tip though the problem was another one... if you noticed the address i was using to go to the other page was user-process. I don't know why but looks like that for some random reason it didn't accept the dash between the two words. I don't understand how could it go to the page but not consider the includes done before, if the problem was in the address itself. I mean to go to the page there was a call from the login form which sent to: http://newlinecode.com/shareit/user-process user-process is given from the htaccess as a parameter to the index file which then includes the real user-process.php file. the problem apparently was that it wanted the address http://newlinecode.com/shareit/userprocess this way instead of ...../user-process At least I now know I shoudn't use such addresses... Thanks for your precious help I learnt many things from you Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343825 Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2012 Share Posted May 7, 2012 It seems you are actually requesting the includes/user-process.php file directly, instead of the main index page. When the includes/user-process.php is requested directly by the browser, the config.php file hasn't been included and none of the files that config.php include/require have been included either. Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343831 Share on other sites More sharing options...
cym0ej12 Posted May 7, 2012 Author Share Posted May 7, 2012 Yeah I know that was the problem... And that was why it would work if I included everything again in the file user-process.php What was causing it though was the way i was calling the file, that to make a SEO friendly url i thought to call it .....com/shareit/user-process instead of ....../shareit/includes/user-process.php and that apparently caused the error in linux. now that i call it ....com/shareit/userprocess it goes just fine Quote Link to comment https://forums.phpfreaks.com/topic/262224-my-script-doesnt-work-on-linux-but-works-well-on-windows-still-apache-help/#findComment-1343835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.