mysql_error problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 * ****************************************************************

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux