--- branches/paul/db_connect.php 2004/03/04 21:19:42 32 +++ branches/paul/db_connect.php 2004/03/18 19:24:54 67 @@ -1,42 +1,68 @@ DATABASE ERROR DEBUGGING

\n"); + printf("mySQL error:
\n(#%s) %s

\n", + mysql_errno(), mysql_error()); + printf("Attempted query:
\n%s
\n", $querystring); + } + + // Gracefully end the HTML stream + @mysql_query ("UNLOCK TABLES"); + die ("
The database is experiencing problems.\n" ); + } - /****************************************************************/ - - /* constants */ - $DEBUG = 0; - - /****************************************************************/ - - /* database parameters */ - $db_nam = "libdata"; - $db_srv = "localhost"; - $db_usr = "libdata"; - $db_pwd = "libdatapw"; - - /****************************************************************/ - - /* establish a connection to the database or bailout */ - $con = mysql_connect ( $db_srv, $db_usr, $db_pwd ) - or die ( "ERROR: Could not connect to database server!" ); - $result = mysql_select_db ( $db_nam, $con ) - or die ( "ERROR: Could not connect to database!" ); - - /****************************************************************/ - - - /* some useful functions */ - - /* return an error message from a failed sql query */ - function sql_err ( $p_sql ) { - printf ( "ERROR: Query failed.
%s
%s: %s
\n", - $p_sql, mysql_errno(), mysql_error() ); - return 1; - } - - /* finish off the html stream and die */ - function bailout() { - die ( "Bailing Out!
\n\n" ); - } - - +} ?>