Jump to content

My script doesn't work on linux, but works well on windows still apache. Help


Recommended Posts

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.

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...

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;
}

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?

 

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.

 

 

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 ;):)

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

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;

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 :)

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.

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.