Error Log

Web hosting discussion, programming, and shared and dedicated servers.
31 posts Page 3 of 4
by drew.phillips » Mon Jan 09, 2017 12:03 pm
Hi, Yes I was testing. I did get the 500 server error, but you see the entries get inserted into the database?

I still don't know why it's throwing that error, but the reason that error.log isn't populating is due to issues with the DOCUMENT_ROOT for PHP scripts. In a child directory (public/), PHP won't move up to the parent directory to find the settings file because the document_root and script_filenames differ, so the custom PHP settings aren't applying to anything except your root directory.

The only useful thing I was able to pull from our error logs was:

Code: Select all

malformed header from script. Bad header=No recipient addresses found i: /nfs/www/httpd/cgi-bin/php53
It would appear that this is being printed before the "Content-type: text/html" header that PHP is supposed to send.
Drew Phillips
Programmer / System Operations, Sonic.net
by drew.phillips » Mon Jan 09, 2017 12:07 pm
It looks like this is due to trying to send a mail() from PHP with no recipient.

I think your loop is problematic:

Code: Select all

do {
$email_address = $row_getAdminEmails['email_address'];
//...
} while ($row_getAdminEmails = mysql_fetch_assoc($getAdminEmails));
This will always result in trying to send one email with an empty To: field.

Reverse that from a do...while to a while.

Code: Select all

while ($row_getAdminEmails = mysql_fetch_assoc($getAdminEmails)) {
    // email
}
This way it won't send an email if no addresses are found, and also won't run that loop iteration on a null value.
Drew Phillips
Programmer / System Operations, Sonic.net
by ErrorLost » Mon Jan 09, 2017 2:07 pm
Thank you for all your help.
I see you turned on display_errors. Thank you. I will have to turn that on/off as I figure this out.

I'll be back in touch if things continue to go south.

Best Regards,
by drew.phillips » Mon Jan 09, 2017 5:11 pm
I tried to but it still didn't help in that case.

Because PHP outputs a warning from the CGI side of things, before Apache can send the HTTP headers, it results in an internal server error.

One thing that you can do in the case of debugging CGI errors like this is to add this at the beginning of the PHP script:

Code: Select all

header("Content-type: text/html");
This will have CGI output the headers so instead of an internal server error you'll see the PHP errors.
Drew Phillips
Programmer / System Operations, Sonic.net
by ErrorLost » Tue Jan 10, 2017 10:52 am
Thank you. The 'header' code worked in displaying general php errors . I finally started getting error.log to populate, but the strange part is that I still get the Server 500 Error on only that single page and it's not logging the 'Why?'

I've uploaded this entire site to my own test domain and everything works as expected, but on this domain (CSL) I get the sever error. It definitely appears related to the Send Email script. I think I will have to come up with a work-around for this part.

I really appreciate your help and willingness to solve this issue.

Best Reagards,
ErrorLost ;)
by drew.phillips » Tue Jan 10, 2017 11:34 am
The error logging isn't working because of the document root issue that prevents files in public/ from seeing the .user.ini in the directory above.

If you copy that .user.ini to public, it should apply those PHP settings, and presumably log those errors even though the request dies at Apache because the headers returned from PHP are invalid.

At the very least, fixing that loop so that it doesn't iterate over an empty recipient should prevent it from generating that one warning about calling mail() with no recipients.
Drew Phillips
Programmer / System Operations, Sonic.net
by ErrorLost » Tue Jan 10, 2017 12:10 pm
Ah. I get it now. Thank you. I've moved the .user.ini file to Public and can now see the error logs.

Thank you for your Loop suggestion. I'm not sure exactly where to edit.
You wrote:
"
Reverse that from a do...while to a while.
So I should change

Code: Select all

do {
 $email_address = $row_getAdminEmails['email_address'];
 //...Email here
} while ($row_getAdminEmails = mysql_fetch_assoc($getAdminEmails));
to

Code: Select all

 while ($row_getAdminEmails = mysql_fetch_assoc($getAdminEmails)) {
    // ..Email here
} 
while ($row_getAdminEmails = mysql_fetch_assoc($getAdminEmails)
??
by drew.phillips » Tue Jan 10, 2017 12:22 pm
That loop is in your public/report_post.php file on line 31.

The first pass through the loop tries to send a blank email because it doesn't actually fetch a row until the end of the loop.
Drew Phillips
Programmer / System Operations, Sonic.net
by perry » Mon Apr 20, 2020 11:09 am
Where are the apache error logs for mini personal web hosting? There is no directory /var/log/httpd as posted previously on this thread.
by joemuller » Mon Apr 20, 2020 2:31 pm
perry wrote:Where are the apache error logs for mini personal web hosting? There is no directory /var/log/httpd as posted previously on this thread.
If you are on shell.sonic.net, they can be found at /logs/by_user/. I'll look into why the seem to have disappeared from ftp.sonic.net.

-- Joe M
Sonic System Operations
I'm a proud employee of Sonic.net! :-)
31 posts Page 3 of 4

Who is online

In total there are 44 users online :: 0 registered, 0 hidden and 44 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 44 guests