Plot: First I had a site with GodDaddy, Furstated of their cool CPanel and more cool downtimes I moved on to Digital Ocean VPS.
Problem: But when I transferred files to VPS I get some common/uncommon PHP errors. I seen no errors when using godaddy. A few of them are.
Notice: Undefined variable: q in /srv/users/someuser/apps/video/public/config.php on line 7
and
Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead
I am using PHP 5.4 (on nginx , the LEMP install)for now. Any way to hide these errors as my site is working flawlessly even when these errors appear.
Instead of suppressing notices and error messages, I would consider fixing the problems. Might be more work to do for now, but I think it's worth the effort in order to have a full running and functioning program in the end - and if Digital Ocean updates libraries your code will break.
Notice: Undefined variable: q in /srv/users/someuser/apps/video/public/config.php on line 7
this notice tells you that there is a variable not set and in which file and in which line. So you should just go to this file, have a look on what is happening in line 7 and try to fix it. It looks like $q isn't needed at all, so try to comment the line out or take a deeper look in your file if the variable is needed elsewhere.
Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead
CURLOPT_SSL_VERIFYHOST with value 1 is deprecated and will be removed as of libcurl 7.28.1. It is recommended to use value 2 instead.
Consider having a look in the file you are running curl and change the line from either
CURLOPT_SSL_VERIFYHOST => true or CURLOPT_SSL_VERIFYHOST => 1
to:
CURLOPT_SSL_VERIFYHOST => 2,
Looks like GoDaddy used outdated (older) versions of the different libraries.
The curlopt setting may be a warning right now, but will break your program as soon as Digital Ocean updates their libraries or you update them.
You can change your php.ini file according to the documentation and avoid the error :
error_reporting = E_ALL & ~E_NOTICE
This will remove notices and coding standards warnings.
Add the following on the top of your script
error_reporting(0);
In your php.ini file, there are two variables for you consider. The first one is for the level of errors captured, and the second is whether or not to show them on the screen.
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
Adjusting these will give you the desired output.
Related
I have a form that allows upload three files at the same time but just one is required. That works fine, my only problem is the following: if I upload three files I haven't any problem but if I upload one or two files (leaving two or one files empties) I obtain the following notice:
Notice: No file uploaded in Unknown on line 0
As much as empty files. The files are uploaded properly without any other problem, but I want remove that notice... or unless hide it, although I prefer remove it. I tried to hide it using
error_reporting(0);
and
ini_set('display_errors',0);
but neither of two worked...
It is the first time that I have problem, if someone could lead me I'd be very grateful due to that I am stuck with it.
If you are having the same problem as me, check with phpinfo() if you are using a debug version of PHP. If you see that Debug Build has a value of yes, your problem will be fixed if you install a live version of PHP instead of a debug version
The Error itself is caused by running a Debug version of PHP 7, see the bug report. As noted by HPierce because it was a Debug build it overrides the usual PHP settings for error_reporting. However as the Original question is actually about how to hide certain [expected] error messages (Notices), my answer is to this detail specifically.
Kevin, the attempted ways to hide errors you've listed in your question would normally work on non-debug PHP builds. However, it is unwise to ignore the errors, rather than solving them at source. It's also (more) unwise to hide all errors simply due to having expected errors appearing.
As it's only a Notice, you can work around it by setting your error_reporting() value as below:
//report all errors except notices.
error_reporting(E_ALL & ~E_NOTICE);
I would suggest this is far wiser than turning off error reporting entirely which is not recommended. If you want to stop errors being output to browser (as referenced by Tina) you can use display_errors.
Perhaps you may also need to set
ini_set('error_reporting', 0);
depending on your php ini configuration?
Also make sure you set it before carrying out any of the code.
Is there any specific way to turn off PHP warnings in cPanel? Or is there a way to disable PHP warnings using code? The reason for this question is following error,
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/fteeloco/public_html/login_process.php:1) in /home/fteeloco/public_html/login_process.php on line 2
The reason for this error is (as I think ) adding white space before the PHP start tag.
Please help.
Move the session_start() in first line of your page. Error will be resolved.
Note: Add it in header file if you you have header (eg: header.php) file separately. Remove from login_process.php
Add session_start() to the start of php pages where you are using Session variables (if not added).
I want to start by saying that: you are wrong! That is not the reason that you see that warning. The reason is that you started the session before, and then you started it again. So look in your code for 2 lines with "session_start()". Even if this is not right, session_start() must be the first line in your script!!!
Now to answer your question!
There are 2 ways to do this:
disable warnings from php.ini
Open PHP.ini file.
In this file search for the phrase “ error_reporting = E_ALL” ,[without inverted commas]
Here replace this with “error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING “
(Show all errors, except for notices and coding standards warnings)
Make sure you change the real enabled part of this , there are certain other examples given in the file.
Restart your PHP + Apache
use the error_reporting() function in PHP like is described in the PHP manual HERE
But I must warn you, nither of this are considered good practice. It is not ok to disable warning, notice or error messages.
Hope this helps! :D
I'd like to see any PHP errors that are occuring, ie the "Expected ; on line 5 of myfile.php" sort of thing. Unfortunately, I cannot seem to figure out how to see this information.
I've set E_ALL, display_errors ON, friendly error messages are turned off, IIS is set to pass-through on errors, what am I missing?
Syntax errors used to show up as stated above on any page; they no longer do. We moved the server to a localhost for development, and I guess didn't mimic exactly the server config. Now I'm stumped.
Tried on IE and Chrome, neither of which show the errors.
Errors are logged in PHP's log file, but I'd still like them to be displayed on the page; at least for now.
UPDATE:
Just tried adding ini_set('display_errors', 'on'); directly into the requested page, and it now works.. but why? Why does it need to be set locally? My PHP.ini file has this declared already.
To answer the first part of the question; to see the errors when using ajax: You can use the developer tools of your browser to see the exact response from the server.
In FireBug for Firefox for example, you go to the Net tab and there you see all ajax request popping up as they happen. Opening one of these requests will give you an overview with more tabs like Response and HTML.
Try using:
error_reporting (-1);
E_ALL isn't really "all" for php < 5.4.
Also, make sure 'display_errors' is set.
ini_set( 'display_errors', 1 );
Well, looks like this is half my own stupidity, half the cloudiness of automatic installations.
Turns out there were TWO php.ini files, and that IIS used the one located within the iis express directory on the main drive, instead of the regular PHP directory.
So to anybody else having this problem, I'm providing the full list of crap you have to wade through to get the errors as you would like:
1) Turn off the IIS default error pages
2) Disable 'friendly error messages'
3) Ensure you are using the CORRECT php.ini file, and change the parameters as needed. Specifically error_reporting and display_errors.
All of this is necessary before seeing all of the error messages you need right in the browser.
I am using WAMP (Apache 2.2.17, PHP 5.4.3) & WordPress 3.4.2.
Everything was fine until I started to add and activate plugins now I get different sort of errors on the front-end/Admin e.g.
"Notice: Undefined index: plugin_version in
C:\repo\wpdev\wp-content\plugins\wp-rss-multi-importer\inc\upgrade.php
on line 11"
And
"Warning: Illegal string offset 'feedslug' in
C:\repo\wpdev\wp-content\plugins\wp-rss-multi-importer\inc\rss_feed.php
on line 21."
IF I deactivate the plugins everything seems to be fine. I have installed WAMP & WP 2X. The plugins work fine on MediaTemple. The error messages vary depending on the plugins. Search Google and came up empty.
These are Notices and Warnings, which optionally show up depending on your PHP error reporting settings. Find your php.ini and set the following:
error_reporting = E_ALL & ~E_NOTICE
Note, you can find your php.ini location using the phpinfo(); function.
According to the author of the plugin you are using, while waiting for an update you can get rid of that error by commenting out these lines in inc/rss_feed.php, e.g.
//if (!empty($feed_options)){
//add_feed($feed_options['feedslug'], 'rssmi_feed');
//}
When I developed a website on my localserver it was working fine.
Now that I've uploaded it live I'm getting several notices.
Notice: Undefined index: ... on line 14
I've figured out that it happens because I'm using variables which arn't defined, and would like to go through and fix it. But I need a live version working tonight.
Is it possible to suppress the Notices and have the website act as it does on my localhost while its on my live server?
You've got it twice wrong. On your localhost and on your live server!
Localhost
Always show everything on screen, you want to know about notices too before you go live, as you can see now!
Live server
Never show anything on screen, it makes you vulnerable (it's deadly)
Log everything, also notices! So don't do what the other answers tell you!
You can choose which kind of errors will show up on your site on a global scale through php.ini or through .htaccess for specific folders, or per script by using error_reporting().
Read more on that and which options to set for your specific needs at www.php.net/manual/en/function.error-reporting.php
Also read: http://www.php.net/error-reporting
Look in the file php.ini for a line similar to error_reporting = E_STRICT - Edit it to remove the STRICT bit and put in error_reporting = E_ERROR.
I would recommend that in the near future that you fix those errors anyway.