mostafamemariani / mysql-cacti-templates

Automatically exported from code.google.com/p/mysql-cacti-templates
GNU General Public License v2.0
0 stars 0 forks source link

ss_get_mysql_stats.php: Error supression on mysql_connect() makes debugging hard #105

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
mysql_connect()-errors are supressed with the @-operator. This error 
supression makes debugging really hard, if the host PHP does not have 
ext/mysql installed. The script will just exit silently with a hidden fatal 
error.

I would suggest adding a condition with extension_loaded('mysql') before 
mysql_connect() and triggering an error.

Original issue reported on code.google.com by lars.str...@gmail.com on 16 Dec 2009 at 11:44

GoogleCodeExporter commented 8 years ago
I've been away from PHP programming for a while.  In your opinion should I 
remove the
@ from the front of the following lines too?

1048 function run_query($sql, $conn) {
1049    global $debug;
1050    debug($sql);
1051    $result = @mysql_query($sql, $conn);
1052    if ( $debug ) {
1053       $error = @mysql_error($conn);
1054       if ( $error ) {
1055          debug(array($sql, $error));
1056          die("SQLERR $error in $sql");
1057       }
1058    }
1059    $array = array();
1060    while ( $row = @mysql_fetch_array($result) ) {
1061       $array[] = $row;
1062    }
1063    debug(array($sql, $array));
1064    return $array;
1065 }

I think I should not -- if those lines cause errors it'll be well handled and
reported, I think.  But I just thought I'd ask your opinion.

Original comment by baron.schwartz on 25 Dec 2009 at 6:50

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r366.

Original comment by baron.schwartz on 25 Dec 2009 at 6:51

GoogleCodeExporter commented 8 years ago
In general: I would suggest du use the ini setting "display_errors" in 
condition with the 
debugging flag. Means: if the debugging option is giving, display errors, if 
not, don't. 
That way, error suppression is not needed, the script will fail gracefully if 
debugging is 
enabled and yield human readable error messages.

Thanks for the fix!

Original comment by lars.str...@gmail.com on 27 Dec 2009 at 12:42