Asked  7 Months ago    Answers:  5   Viewed   36 times

I am testing a website online.

Right now, the errors are not being displayed (but I know they exist).

I have access to only the .htaccess file.

How do I make all errors to display using my .htaccess file?


I added these lines to my .htaccess file:

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

And the pages now display:

Internal server error

 Answers

67

.htaccess:

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log
Wednesday, March 31, 2021
 
Savageman
answered 7 Months ago
48

You could pass ob_start the name of a callback function, that is executed before the output is flushed on ob_get_clean().

This callback function seams to be executed even if an error occured on the page.

This way you could do something like this:

<?php
$endReached = 0;

function outpu_cb($buffer) {
  global $endReached;

  if ($endReached) return $buffer;
  else return 'Your error message';
}

// Start the output buffer
ob_start('outpu_cb');

// Output something into the buffer.
// I only want this to be displayed if I call one of the
// ob_flush functions or echo the buffer myself later.
echo "yep";

// Call a function I know not to exist in order to raise
// an error which cannot be trapped by set_error_handler()
// and would, if display_errors was On, output "Fatal
// error: Call to undefined function fwee()..."
function_which_does_not_exist();

// This will never be executed.
$endReached = 1;
echo ob_get_clean();
?>
Saturday, May 29, 2021
 
uiroshan
answered 5 Months ago
40

Customized Error 500 pages are the hardest to use. The problem is, there are many reasons why a server can throw a 500 internal server error. Custom pages for 500 only work if the cause of the 500 can be handled by Apache to display the page. Say for instance you made a syntax error in your .htaccess page or in your apache config file, it's going to throw a 500 server error but because Apache is down, it can't serve anything including that custom page, so you get the browsers default page. Also depending on how you have your PHP error reporting setting you won't get 500 custom page either. There is a lot more to this and customizing 500 page is almost useless cause most people won't ever see that. You will know before they will because it's a 500 is typically configuration issue, like a syntax error in your code.

503 is the most common page a user will see especially if your site is down for maintenance and those are the one's I would focus on.

Anyway, I'd take a look at this link to see more info on 500 custom pages on when and why it won't work.

Apache's ErrorDocument directive does not redirect.

Also from Apache docs

Although most error messages can be overridden, there are certain circumstances where the internal messages are used regardless of the setting of ErrorDocument. In particular, if a malformed request is detected, normal request processing will be immediately halted and the internal error message returned. This is necessary to guard against security problems caused by bad requests.

http://httpd.apache.org/docs/2.4/mod/core.html#errordocument

Saturday, May 29, 2021
 
phpmeh
answered 5 Months ago
21

All you need to do is to click on the WAMP server icon in the system tray and go to mySQL and my.ini. Open the file in a text editor like notepad. At the top of the page there should be a line

socket = /tmp/mysql.sock

change that to

socket = c:/tmp/mysql.sock

Save the file and try running phpmyAdmin. Restart wamp. It should work perfectly.

If this does not fix the error for you let me know and I will try and help.

Saturday, May 29, 2021
 
Eugenie
answered 5 Months ago
54

The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:

  1. Find your version of PHP: php -v.
  2. Download the version of PHP that matches yours: curl -O http://us.php.net/distributions/php-5.3.3.tar.gz. (This example downloads PHP 5.3.3 but this must match your version)
  3. Extract the archive you downloaded: tar -xzvf php-5.3.3.tar.gz
  4. Change to the PostgreSQL's extension directory: cd php-5.3.3/ext/pgsql/
  5. Type phpize.
  6. Type ./configure.
  7. Type make.
  8. Type sudo make install.
  9. Add the extension to you php.ini file by adding extension=pgsql.so. (You may already have done this)
  10. Restart Apache.

Update for OS X Mountain Lion Apple has removed autoconf from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:

  1. Type /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)".
  2. Type sudo chown -R $USER /usr/local/Cellar.
  3. Type brew update.
  4. Type brew install autoconf.

That should install autoconf and allow you to install the module using the instructions above.

Saturday, June 12, 2021
 
fardjad
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :