For full details check your web logs for the code '$err_ref'" ); } function dbEscape( $string ) { if ( version_compare( phpversion(), "4.3.0", "<") ) return( mysql_escape_string( $string ) ); else return( mysql_real_escape_string( $string ) ); } function dbQuery( $sql ) { if ( dbDebug( $sql ) ) return; dbLog( $sql ); if (!($result = mysql_query( $sql ))) dbError( $sql ); return( $result ); } function dbFetchOne( $sql, $col=false ) { dbDebug( $sql ); dbLog( $sql ); if (!($result = mysql_query( $sql ))) dbError( $sql ); $db_row = mysql_fetch_assoc( $result ); return( $col?$db_row[$col]:$db_row ); } function dbFetchAll( $sql, $col=false ) { dbDebug( $sql ); dbLog( $sql ); if (!($result = mysql_query( $sql ))) dbError( $sql ); $db_rows = array(); while( $db_row = mysql_fetch_assoc( $result ) ) $db_rows[] = $col?$db_row[$col]:$db_row; return( $db_rows ); } function dbFetch( $sql, $col=false ) { return( dbFetchAll( $sql, $col ) ); } function dbFetchNext( $result, $col=false ) { $db_row = mysql_fetch_assoc( $result ); return( $col?$db_row[$col]:$db_row ); } function dbNumRows( $sql ) { dbDebug( $sql ); dbLog( $sql ); if (!($result = mysql_query( $sql ))) dbError( $sql ); return( mysql_num_rows( $result ) ); } function dbInsertId() { return( mysql_insert_id() ); } function getEnumValues( $table, $column ) { $enum_values = array(); $row = dbFetchOne( "DESCRIBE $table $column" ); preg_match_all( "/'([^']+)'/", $row['Type'], $enum_matches ); $enum_values = $enum_matches[1]; return( $enum_values ); } function getSetValues( $table, $column ) { return( getEnumValues( $table, $column ) ); } function getUniqueValues( $table, $column, $as_string=1 ) { $values = array(); $sql = "SELECT DISTINCT $column FROM $table WHERE (NOT ISNULL($column) AND $column != '') ORDER BY $column"; foreach( dbFetchAll( $sql ) as $row ) { if ( $as_string ) $values[$row[0]] = $row[0]; else $values = $row[0]; } return( $values ); } function getTableColumns( $table, $as_string=1 ) { $columns = array(); $sql = "DESCRIBE $table"; foreach( dbFetchAll( $sql ) as $row ) { if ( $as_string ) $columns[$row[Field]] = $row[Type]; else $columns[] = $row[Type]; } return( $columns ); } function dbFetchMonitor( $mid ) { return( dbFetchOne( "select * from Monitors where Id = '$mid'" ) ); } function dbFetchGroup( $gid ) { return( dbFetchOne( "select * from Groups where Id = '$gid'" ) ); } ?>