Page 1 of 1
NOW WITH CODE - Cause of "Internal Server Error"??
Posted: Mon Apr 10, 2006 6:55 am
by mattcooper
Hello,
Have just finished a script that dynamically creates directories and copies files into them. Have checked the folders' permissions etc, as well as the files copied into them, and all are set to 0700 (have also tried with 0755).
I cannot view the files and am getting an internal server error page. What is the usual cause of this??
Thanks in advance..
Posted: Mon Apr 10, 2006 7:01 am
by timvw
Simply look in your error_log file and you'll get the actual cause (which seems more interesting than the usual cause).
Posted: Mon Apr 10, 2006 7:02 am
by JayBird
could be for many different reasons...i usually get it for file permissions errors.
Best thing to do is look for more deatil in you error.log file
Posted: Mon Apr 10, 2006 7:18 am
by mattcooper
That was the first thing I looked for - unfortunately, there isn't one for some reason. Permissions on all contents of the newly created files and dirs set to 0700, as I understand that the usual cause is setting them to anything else...
having tweaked the code a bit to make sure everything gets chmodded correctly, I'm now getting a "Forbidden" error...
Nightmare! Any other thoughts?
Posted: Mon Apr 10, 2006 7:59 am
by JayBird
what is the script actually trying to do when you get the error?
you really should have an error log for instances like this.
I would suggest making sure you have error logs enabled
Posted: Mon Apr 10, 2006 8:17 am
by mattcooper
Pimptastic wrote:what is the script actually trying to do when you get the error?
you really should have an error log for instances like this.
I would suggest making sure you have error logs enabled
Right, have checked the server error log... sorry, was looking for one on the ftp server! These two entries cause a bit of concern but I don't really know what to do about them:
[2006-04-10 08:03:50]: error: directory is writable by others: (/home/sageinte/public_html/eman/3970141)
[Mon Apr 10 08:09:05 2006] [crit] [client 62.30.182.68] (13)Permission denied: /home/sageinte/public_html/eman/7899586/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
I read something about htaccess a while ago, but I'm not too sure what needs to be done.
Permissions on all folders are set at 760, and files are 0755.
The script I am trying to display is the index.php file copied during the dynamic generation of the folders and their contents.
Code: Select all
// Index.php - resides in the root folder of the site as well as being
// copied into each ezine's newly created folder.
// When it loads, it checks the name/attributes of the directory in
// which it is residing, and displays content accordingly.
// If it is in a folder that has a numeric name, it will display the ezine
// for that folder. if it is in the site's root folder (i.e, a non-numeric
// directory), it will display welcome content for the ezine manager and a
// click-thru to manager.php
// Get the directory name
$self = $_SERVER['PHP_SELF'];
$split = explode("/","$self");
$folder = $split[2];
// Returns the directory id - naw test to see if it's a number:
if(is_numeric($folder)){
include "../includes/db_connect.inc.php"; // because we're about to connect to the database to get content for an ezine
mysql_connect($host,$uname,$pword);
mysql_select_db(sageinte_ezines);
// Now we have to establish which template to pull in to display the content
$query = "SELECT template FROM preferences WHERE ezine_id = '$folder'" or die ("There has been a technical fault");
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$template = $row[0];
// We should now have a number - the default is "0", since we inserted this at the creation point. This means that
// a message should now be displayed prompting the viewer to log in and start adding content
if($template=="0"){
include "templates/generic_template.php"; // the generic ezine sample
}
else{
ezine(); // call the function that creates the ezine!
}
}
else{
//include "includes/welcome.php";
}
// Function ezine() - calls the correct code for the layout chosen and populates the ezine!
function ezine(){
include "../includes/db_connect.inc.php"; // because we're about to connect to the database to get content for an ezine
mysql_pconnect($host,$uname,$pword); // opens a persistent connection
mysql_select_db(sageinte_ezines);
$query = "SELECT template FROM preferences WHERE ezine_id = '$folder'" or die ("There has been a technical fault");
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$template = $row[0];
$file = "../templates/{$template}.php";
$layout = file_get_contents($file) or die ("Couldn't perform the requested action - file {$layout} doesn't exist!");
} // end function
Does this shed any light on things? It doesn't appear that it is a server error because if I rename the file with an html extension, it displays the code. I'm guessing, therefore, that somebody's going ot spot a code error...