Re: Stricter Error Checking?

From: Date: Wed, 23 Sep 2009 20:35:53 +0000
Subject: Re: Stricter Error Checking?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-298302@lists.php.net to get a copy of this message
Tim Legg wrote: > Hello, > > I just spent way, way to much time trying to debug code due to a misnamed element. Here is a > simplified example of the problem I dealt with. > > > $test = "SELECT * FROM Materials WHERE > Part_Number = '125664'"; > $result = mysql_query($test,$handle); > if(!$result) > { > die('Error: ' . mysql_error()); > } > $row = mysql_fetch_array($result); > echo $row['Number']; > > After retyping the code 3 or 4 times over the course of the morning, I finally found where the > problem was. The problem is that the database field is called 'Part_Number', not > 'Number'. The field 'Number' does not exist in the database. I am very > surprised that I didn't even get a warning that there might be a problem with the statement. > All I saw is that nothing was being returned via the echo command. > > There really must be a stricter error checking that is turned on somewhere, isn't there? > > > Thanks for your help. > > Tim > > > > This would generate a E_NOTICE level "warning" to see the errors of you ways you would need the following at the top of your script, or set in your php.ini file or in a .htaccess file. In script example: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ... ?> .htaccess & php.ini example: error_reporting = E_ALL display_errors = On The default setting in PHP error_reporting = E_ALL & ~E_NOTICE display_errors = On

« previous php.general (#298302) next »