mysql_error problem

From: Date: Mon, 23 Jun 2003 23:45:57 +0000
Subject: mysql_error problem
Groups: php.general 
Request: Send a blank email to php-general+get-152552@lists.php.net to get a copy of this message
I am using the below function (error_db) witch is called thus:- function query_db( $sql, $db ) {
    $result = mysql_query( $sql, $db ) or
      error_db( $sql, $db );
    return $result;
} But $sqlerr is always blank (it is set with '$sqlerr = mysql_error( $db );'). Any idea why? Ben function error_db( $sql, $db ) {
    global $SERVER_NAME;
    global $SCRIPT_NAME;
    table_top( "Database Error" );
    table_middle();
    $sqlerr = mysql_error( $db );
    echo "<b>SQL:</b>:<BR>$sql<br><b>Error:</b><BR>$sqlerr";
    table_bottom();
    // Clost of table/html from calling script
    table_bottom();
    html_footer();
    // Send error via email
    $msg  =
      "Database error has accured on $SERVER_NAME\n\n.".
      "The error message is :-\n\n".
      "SQL:$sql\n\nError:$sqlerr\n\n".
      "This message was ".
      "generated by '$SERVER_NAME$SCRIPT_NAME'";
    $subj = "Database error from $SERVER_NAME";
    // Hard coded to minimize chance of this module erroring
    $to   = "ben@videonetwork.org";
    $from = "From: ".$to;
    mail( $to, $subj, $msg, $from );
    die();
} ****************************************************************
* Ben Edwards           Tel +44 (0)1179 553 551  ICQ 42000477  *
* Homepage - nothing of interest here http://gurtlush.org.uk *
* Webhosting for the masses         http://www.serverone.co.uk *
* Critical Site Builder    http://www.criticaldistribution.com *
* online collaborative web authoring content management system * * Get alt news/views films online http://www.cultureshop.org *
* i-Contact Progressive Video      http://www.videonetwork.org *
* Fun corporate graphics             http://www.subvertise.org *
* Bristol Indymedia               http://bristol.indymedia.org *
* Bristol's radical news             http://www.bristle.org.uk *
****************************************************************

« previous php.general (#152552) next »