Quick fix for "PHP Notice: Undefined variable" errors PHP 5.0 / 5.1 / 5.2 / 5.3 / 5.4

A little something about everything

internet marketing and website development made simple..

Quick fix for "PHP Notice: Undefined variable" errors PHP 5.0 / 5.1 / 5.2 / 5.3 / 5.4

After taking over an account from another firm, the customers site was getting errors like this? Generally I would rewrite the code into asp.net however I was in a hurry to find a quick solution.

Example of the errors:

PHP Notice: Undefined variable: city in path\dbconnect.PHP on line 3 PHP Notice: Undefined variable: state in path\dbconnect.PHP on line 4 PHP Notice: Undefined variable: ownership in path\dbconnect.PHP on line 5 PHP Notice: Undefined variable: priceMin in path\dbconnect.PHP on line 6 PHP Notice: Undefined variable: priceMax in path\dbconnect.PHP on line 7 PHP Notice: Undefined variable: bedMin in path\dbconnect.PHP on line 8 PHP Notice: Undefined variable: bedMax in path\dbconnect.PHP on line 9 PHP Notice: Undefined variable: bathMin in path\dbconnect.PHP on line 10 PHP Notice: Undefined variable: bathMax in path\dbconnect.PHP on line 11 PHP Notice: Undefined variable: sqftMin in path\dbconnect.PHP on line 12 PHP Notice: Undefined variable: sqftMax in path\dbconnect.PHP on line 13 PHP Notice: Undefined variable: acreMin in path\dbconnect.PHP on line 14 PHP Notice: Undefined variable: acreMax in path\dbconnect.PHP on line 15 PHP Notice: Undefined variable: yearMin in path\dbconnect.PHP on line 16 PHP Notice: Undefined variable: yearMax in path\dbconnect.PHP on line 17 PHP Notice: Undefined variable: garageMin in path\dbconnect.PHP on line 18 PHP Notice: Undefined variable: garageMax in path\dbconnect.PHP on line 19 PHP Notice: Undefined variable: listingID in path\dbconnect.PHP on line 20 PHP Notice: Undefined variable: ADDLISTING in path\dbconnect.PHP on line 21 PHP Notice: Undefined variable: UPDATELISTING in path\dbconnect.PHP on line 22 PHP Notice: Undefined variable: deletePhoto in path\dbconnect.PHP on line 23 PHP Notice: Undefined variable: deleteDisclosure in path\dbconnect.PHP on line 24 PHP Notice: Undefined index: priceMin in path\basic.PHP on line 4 PHP Notice: Undefined index: priceMax in path\basic.PHP on line 5 PHP Notice: Undefined index: state in path\basic.PHP on line 6 PHP Notice: Undefined index: city in path\basic.PHP on line 7 PHP Notice: Undefined index: ownership in path\basic.PHP on line 8

Obviously the site is using invalid code and the newer php5.x is more than happy to tell you about it.

You can fix your code or you can simply disable the error reporting:

 

Be sure to place the code inside your php tags:

 

Add comment

Loading