Re: mysql not reporting errors

From: Date: Fri, 09 Feb 2001 22:12:18 +0000
Subject: Re: mysql not reporting errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39029@lists.php.net to get a copy of this message
----- Original Message ----- From: "Christian Dechery" > WHy PHP is not showing SQL syntax (or any) errors? > > I'm using Win98Me with Apache 1.3.12 and PHP 4.x. > > it works... if I run a correct query it runs normally, but if I go like: > > $query="selct nonexistingfield from nonexistingtable with all crazy syntax"; > mysql_query($query); > > it doesn't tell me there's an error... in fact it doesn't show anything... > why is that? Because it's a pain to have error messages popping up all the time? Here is what I do with every query I every write: $query="yada yada"; $result=mysql_query($query, $connection); if($result=="" || $result=="0") { //if it is a page for my use, I print the error // if it is a page for the general public, I email the //error to myself, and print "There was a problem //completing your request", or something like that. print "Error : ".mysql_error($connection)."<br>\n"; } else { while($row=mysql_fetch_row($result)) { //do whatever you want to do with the data. } } I greatly prefer this to display "0 is not a mysql result index" for everyone to see, if/when something goes wrong. Anna

« previous php.general (#39029) next »