I have moved my php site to a new host but this is causing massive problems, namely with the require(mysqli_connect.php) which, ofcourse is to connect to the database. Any file that has this require does not load up, leaving just a blank page. These pages worked perfectly fine before switching and work fine if I comment out the require. Would the db not connecting cause this require to fail?
I haven't used php for 2 years+ now, so sorry if this is not enough detail, but not sure what more I can give.
Mysqli might not be installed on that server. Either ask the admin of the server to solve this problem, or if it is yours, check this out:
http://www.php.net/manual/en/mysqli.setup.php
Enable PHP error reporting to see what the error really is. In the script itself, before the require('mysqli_connect.php'):
error_reporting(E_ALL);
or in .htaccess file
php_flag display_errors on
php_value error_reporting E_ALL
Related
I've tried setting WP_DEBUG and WP_DEBUG_DISPLAY to false. After that, I've tried following in wp-config:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Still, PHP warnings and notices are shown on the frontend. I've also checked with ini_get before and after setting ini vars, looks like it's properly set everything, but notices and warnings are still shown.
If I clone website locally or to different host, everything works properly, ie. notices and warnings are hidden. Is there anything else I could try?
This is not a wordpress issue but tied to your server setup and php configuration.
Option 1: Make sure error output is disabled on server side
If you have access to your hosting admin area (... maybe something like plesk or a custom admin ui): search for something like:
error reporting
php settings
php.ini
Usually you'll see some options like:
show only critical errors and omit notices
log errors to a log file
disable all error messages and logging
Nothing?
Contact the hosting provider's support (or web admin), where to set this configuration. (This should actually be default in every hosting environment – even with most basic shared hosting setups).
Option 2: Dirty Hacks/overridung
php-script
htaccess directives
2.1 If your theme has a global header template part/include like "header.php" that's included/required before any html output, you could add a php function like
<?php
error_reporting(0);
<?>
This should work pretty much everywhere – still a temporary solution. If you're using a regularly updated theme – this hack will be deleted after every update.
2.2 htaccess directive
Jeff Starr has elaborated on this approach
If you have access to a .htaccess file you might try to add these directives
# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
Actually ... not a valid solution either.
.htaccess will only work if you're on an apache driven webserver (even then – based on your apache version, specific compiled version, configuration ... quite a lot of snippets just won't work).
Maybe your website isn't even hosted on an apache webserver but instead nginx or even IIS ... etc.
Before checking other options, you might check your current webserver/php setup by
uploading a test.php file with this content to your root dir
<?php phpinfo(); ?>
Delete this file after checking your setup. In particular interesting wether you're on apache or nginx etc.
Conclusion
Make sure to disable error handling on the server side. So stick with proper server configs and don't waste too much time with any hacks! (... we all need them now and then!)
You can check on your server setting and make error reporting off.May be it will works
i'm about to set up my first own VPS for my website. cPanel is installed, PHP and MySQL are up to date.
I get some "Strict Errors" on my website, the errors are not a bad thing, but it looks not so nice of course. In my php.ini display_errors is set to off, of course. Because i use cPanel, i can upload a php.ini in the root folder of my user account. This works and should be the local value. But the errors still persist. Now, i got myself a php file with <? phpinfo(); ?> and uploaded it to the root of my user folder. Looks like this. You can see, display_errors local and master value are off. Now, when i go to my Joomla System Information and look into the php information, i see this. Here is the local value on. But why?! There is nothing in the .htaccess and when i write something in there like php_flag display_errors off it breaks my page with 500 Internal Server Error. Of course, i cleared the cache of Joomla and i tried to find another string with "display_errors", but no luck so far.
It's been working for ages and stopped. I must be missing something obvious.
File /etc/php5/apache2/php.ini relevant settings are:
display_errors = On (I am not sure if this makes a difference)
log_errors = On
error_log = "/var/www/error_log.log"
In my code I have:
echo 'About to log';
error_log('An error');
I see "About to log" on the page, but nothing in the error log. How can I fix this?
Restart the Web server. Until you do php.ini changes are not considered.
Also, if you want to track PHP errors, you need to have track_errors=On and error_reporting=E_ALL, although that is not related with error_log calls. Also make sure that the error log file is writeable by the Web server user.
It ended up being permission issues. The file grew too big to open quickly, so I deleted and recreated it, but with read-only permissions.
I totally forgot I deleted it. What a pain.
In my php.ini file (XAMPP default), there was a second entry for error_log overriding the one that I had set.
So if the other answers do not work for you too, search again for multiple entries of the necessary settings.
I was a Windows user and used Wamp. Every time a PHP code failed, the browser would display something like this: error in line number xx.
I followed the installation of this tutorial and everything worked.
Now when code fail PHP just display a blank page.
Any sugestions?
(I'm using Ubuntu 10.04).
I know this is a old post, but I had the same problem and found out that after error_reporting, there is a option of display_errors, change it to On.
Old question, as Gurnarok noted, but still, here's the answer.
The standard LAMP server installation on Ubuntu does this. I simply call it "production" mode, i.e. your pages don't display errors (to your users) when your site goes live. I rather like that it does this, but I was confused at first, as well.
Instead of editing my php.ini file to go into "development" mode, I simply place this at the top of my PHP files (or, PHP file, in my case, since I usually pass everything through index.php):
ini_set('display_errors', true);
error_reporting(E_ALL ^ E_NOTICE);
So, the reason why error_reporting by itself isn't doing the trick, is most likely because display_errors isn't set to true in your php.ini file. The code above should take care of that.
I prefer to exclude the PHP "Notice" notification, such as notifications about non-existent array keys (the most common Notice, in my case), but you're perfectly welcome to simply change this to error_reporting(E_ALL);
Of course, you can set these variables in the php.ini file, I simply prefer it this way, so that when the site goes live, I simply remove those two lines from index.php and I'm in no danger of errors showing up to my users.
Find php.ini under /etc/php5/apache2/ and set the value of error_reporting to E_ALL. Like:
error_reporting = E_ALL
Or alternatively check error.log if your virtual host is providing one.
Thanks Phil your answer got me thinking and I finally managed to fix an issue thats been bugging me for weeks where my PHP install wasn't displaying errors in the HTML page at all (except sometimes a notice message but never any syntax errors etc). Even though I had all other error settings set to "on" and log_errors set to on and a filename for the log only notices were getting logged to the log file but never any syntax errors. Not very useful on a development server :)
Thought I would post my findings here in the hope that this info can help someone else with the same issue as Google wasn't very helpful with fixing the issue.
In older versions of PHP before PHP 5 I used to always have my error reporting setting in PHP ini set to "E_ALL & E_NOTICE" on my development servers. In later versions of PHP (well with my Ubuntu Oneric install anyways) using this setting seems to cause no output to be displayed at all in the HTML page regardless of the other php.ini settings (like display_errors = on, etc). Setting the values on the fly in a PHP page didnt help either as it seems the php.ini value overrides the per file setting.
I changed the error_reporting value to "E_ALL" only and now it displays syntax errors. The setting recommended in php.ini for a development server (E_ALL | E_STRICT) doesnt work for me either so thanks a lot. +1 to you :)
I am running the latest version of MAMP on Snow Leopard.
My php.ini file has been configured to display errors. display_errors = on. The phpinfo(); page displays the status of error reporting, it is on. I have restarted my web server several times.
I've searched through Google, and I cannot find any similar problem. Everyone just says to do exactly what I have done, but it is not working. The pages will just remain blank, (with no reporting), if I intentionally place errors.
Any thoughts as to what the problem may be?
For any future posters who run into this issue...
I was having the same issue and found that I was making changes to the wrong php.ini files. Run phpinfo and find the path to the active php.ini file to make sure you're editing the correct one.
On my installation of mamp there were multiple instances of the /conf directory with php.ini files. The php.ini files I needed were located in the /bin/php/php[version#]/conf directory and not the MAMP/conf directory.
Exact path to the php.ini file I needed to edit:
Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Change display_errors = Off to display_errors = On
In addition to the display_errors directive, which has to be set to On, you might have to configure error_reporting.
For instance, you can use this in your php.ini file :
error_reporting = E_ALL
Another should, useful to test, might be to place this kind of portion of PHP code at the beginning of your script :
error_reporting(E_ALL);
ini_set('display_errors', 'On');
This is useful when you don't have access to php.ini and/or just want to test quickly, without having to restart the webserver.
As a sidenote, when it comes to displaying errors, the Xdebug extension is really great : when it's installed/enabled/configured, instead of just having an error message, you'll get the full stack-trace, which is much more useful ;-)
I recently experienced the same problem - in my case I had downloaded a client's Wordpress site from their live server that turned out to have been tampered with by malicious script insertion that was overriding the error reporting in order to escape detection.
A little late to help the OP(!), but perhaps of use to future searchers.
There might have a .htaccess file in a directory that overrides the display_errors setting set in php.ini. From your post I assume you didn't explicitly add this but a few frameworks do this by default so might be added that way. Look for a line like this in your .htaccess file:
php_value display_errors 0
and change the value to 1.
If you have several php sdks with several versions, first make it sure you are editing correct php.ini file. If you were right add this two lines at the beginning of the code.
error_reporting(E_ALL);
ini_set('display_errors', 'On'); // or ini_set('display_errors', 1);
Here's a twist to the same answer. I had the same issues, just copied and pasted the ini path from the php info page and still same problems...
turns out I made a syntax mistake when I edited my 'error_reporting' block in the php.ini.
I had E_NOTICE rather than ~E_NOTICE.
:(
So mistakes can happen in the php.ini if you were editing it and totally forgot you edited something.