PHP, MySQL and exception handling

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • OneSolution

    #1

    PHP, MySQL and exception handling

    I want to find out how I can ensure that if MySql has a burp and can't write
    to my DB, I will have a way of capturing the error and show my users
    something more pleasing than a system error message.

    Is this something that's a part of PHP-MySql combo? I currently use MS
    Access, and it sucks ... if there is a DB write error, or the DB gets
    locked, then my user sees this glaring error message ... (BTW if you know
    how to get by that one, do let me know ... it's an immediate issue for me
    .... I appreciate it). I'd rather try to have their data e-mailed to me or
    something.

    Thanks,
    Santosh


  • Jedi121

    #2
    Re: PHP, MySQL and exception handling

    "OneSolutio n" a écrit le 19/11/2003 :[color=blue]
    > I want to find out how I can ensure that if MySql has a burp and can't write
    > to my DB, I will have a way of capturing the error and show my users
    > something more pleasing than a system error message.[/color]

    Of course you can, just check the doc http://www.php.net/
    use the following functions :
    mysql_errno()
    mysql_error()
    to get the error message.

    You can add an "OR DIE()" function after your SQL command like

    $db = mysql_connect( $server, $user, $pass ) or die("Can't connect to
    DB!");


    Comment

    • OneSolution

      #3
      Re: PHP, MySQL and exception handling

      Cool. So when it "dies", then does that mean the rest of the code can
      execute through an error scenario or does it stop running the script?
      Basically, I don't want a system error message getting to my user. I want
      to have the opportunity to tell my user something other than the actual
      technical error message.

      Thanks,
      Santosh

      "Jedi121" <jedi121news@fr ee.fr.Removethi s> wrote in message
      news:mesnews.9c bd7d3b.ca91be6e .161.2689@free. fr.Removethis.. .[color=blue]
      > "OneSolutio n" a écrit le 19/11/2003 :[color=green]
      > > I want to find out how I can ensure that if MySql has a burp and can't[/color][/color]
      write[color=blue][color=green]
      > > to my DB, I will have a way of capturing the error and show my users
      > > something more pleasing than a system error message.[/color]
      >
      > Of course you can, just check the doc http://www.php.net/
      > use the following functions :
      > mysql_errno()
      > mysql_error()
      > to get the error message.
      >
      > You can add an "OR DIE()" function after your SQL command like
      >
      > $db = mysql_connect( $server, $user, $pass ) or die("Can't connect to
      > DB!");
      >
      >[/color]


      Comment

      Working...