Php.ini problems

I am trying to get rid of all the error messages strewn across a contact form I have on my localhost configuration

Every time I make an edit to the error_reporting line, the MariaDB server stops working as if a file is missing, I know this file isn’t missing because I have seen the said file in the folder

The error message that is strewn across the contact form is


Notice: Undefined variable: nameField in D:\xampp\htdocs\xxxx\contact.php on line 75

That is one sample because there are multiple error messages of a similar nature

And the line with the error reporting is

error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT

That means that the variable is undefined. You need to define it.
The error is definitely in the contact.php file and most likely on or just before line 75.

The same will be the case for all the other errors - something not right in the PHP file it refers to on or just before the line referred to.

No change to your error reporting is required unless you want to get rid of everything from the first & onward so as to not hide some of the errors.

1 Like

For setting the error reporting level use:

error_reporting(-1);

That will report absolutely every error

I have set it, though since it gets the value of what is being processed after the submit button is clicked

If you’re still getting that error message then you probably need to set the variable somewhere else as well. It is probably better to fix the errors and warnings rather than change the level of error reporting on your development system.

I won’t get this error message on remote server, but only on localhost

I need to check a particular script locally than to find out it’s knocked out the rest of the script

You will - if you get the error locally then you will also get it anywhere else. The only difference is that on live servers it is common to suppress displaying the error on the page itself (where it makes it easier for someone to break into your site) and simply record the error in a log file instead.

The whole purpose of displaying ALL errors on your local machine is so that you can FIX them rather than having the live copy generate huge log files.

(for example - I just upgraded my local server from PHP 5.3 to PHP 5.6 and are now seeing error messages that were not there before which I now need to fix before I can make the same PHP update to the live copy of my site).

Oh please stop it, will you

you have to do that by fixing the errors - no one else can stop the errors for you.

1 Like

I think OP is missing the point. Yes, it is important to get rid of these errors, but if you’re going to suppress it. You’re being lazy and shouldn’t be called a developer (don’t kill me if I touched a nerve).

The problem you are not understanding is that if you get rid of this error and more errors show up, then you can correct those errors as well and by the time you are done correcting any errors in any files. both live server and local server have no errors.

I probably bet the only reason why the live server didn’t show these errors is either the hoster you are using don’t have error logging and display on as default or you turned them off by yourself. This is not a good idea.

Moreover, if you keep suppressing errors, more errors on other pages might occur where you don’t want them to. So it is best that you correct this now before other people see more errors and complain about them.

having the errors to display for everyone is not a good idea - having them logged so you can see them later so as to fix them is essential (you might even say critical) - of course if you have tested properly before uploading then all the errors should have already been fixed (but the chances of that are remote as someone is bound to try doing something you didn’t think to test for at some point).

The most important part of all of this though is to make sure that ALL errors on your local system are displayed so that they can be more easily spotted and fixed.

2 Likes

Is the value for $nameField coming from a form? If it is check then check the spelling of the field name and that the form method ties up with the superarray (either $_GET or $_POST) that you’re trying to access the value from (hopefully you’re validating the submitted data)

There is no spelling errors and it does tie with super array $_POST. I had suppressed these errors before, but unlike before, if I attempt to suppress them this time around, MariaDB (what a stupid name for a DB server), I originally had MySQL and that is why the suppression worked. If I attempt suppression with MariaDB, it gives out an error message, saying that a file that is needed for MariaDB to work

I think PHP wants me to state the variables before the IF statement

Never had to do this in the first place

Yes, you need to define the variable before you use it (including testing it).

This wasn’t need last PHP5.6.xxx version

I had a similar problem when I upgraded some while ago. What version of PHP are you on?

PHP version 5.6.15

Ah, well it wasn’t the version of PHP then - mine is 5.5.15

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.