Question

This is the code i have problem with: http://tutsforweb.blogspot.hu/2012/02/php-installation-script.html

Notice: Undefined variable: pre_error in C:\wamp\www\torolni\install.php
on line 110 Call Stack #TimeMemoryFunctionLocation 
10.0022297152{main}( )..\install.php:0 20.0022297824step_2( )..\install.php:13

I have the same problem,as the first commenter, but i don't know how to "close Notice message in your php ini file". What is that? Where can i find it? I use WAMP. Could it be a problem in a "real" server? (Not in localhost)

I can't go to the 3rd step because of the error. Help me please.

Was it helpful?

Solution

They are suggesting to not display PHP notices, but I think it is bad advice because instead of fixing possible code problems that method just hides the message. Fixing the probem would be to initiate the variable:

function step_2(){ $pre_error = ''; //... }

OTHER TIPS

Let me start off by saying turning off notices to hide your PHP errors is not very good practice at all!

Looking at the error, you cannot echo a non-existent variable. $pre_error is not defined in the case where things work correctly. You can declare this at the start of 'Step 2'.

function step_2(){
    $pre_error = '';
    if....

It would also be a good idea to update the conditionals in the if statements so that you check the array key exists before testing it's value. E.g. && $_POST['pre_error'] != '' should change to && (isset($_POST['pre_error']) && $_POST['pre_error'] != '')

Click on your WAMP icon in the taskbar > PHP > php.ini. This will bring you to the text file that sets up your basic PHP behaviors. You can customize those behaviors by following this reference: http://www.php.net/manual/en/function.error-reporting.php

Also, please don't make a PHP installation script. All sorts of security issues will rear their ugly head, especially if you're not using secure FTP over SSL.

To find your php.ini file:

Option 1: Navigate to the corresponding folder on your computer and open the php.ini file with notepad. on mine it is specifically C:\wamp\bin\apache\Apache2.2.17\bin (Your exact location and version of php may be slightly different.

Option 2 Click on the wamp icon in your system tray->PHP->php.ini

In notepad hit ctrl+f and search for display_errors = On. set this to display_errors = Off

Restart your wamp server and the notice should no longer be displayed

This is a very poor fix however as others have mentioned. I would also recommend you turn them back on when you are finished with that tutorials as displaying errors is invaluable when developing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top