Display server error

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

    #1

    Display server error

    Is there a way, using PHP, to detect and display an error from a MySQL
    server? Can I, by using error numbers or some similar method, create my own
    error messages?

    tia
  • Janwillem Borleffs

    #2
    Re: Display server error

    Bob Sanderson wrote:[color=blue]
    > Is there a way, using PHP, to detect and display an error from a MySQL
    > server? Can I, by using error numbers or some similar method, create
    > my own error messages?
    >[/color]


    Sure, you can suppress the error message by preprending an at sign "@" to
    the mysql_* function call and get the error code from the string returned by
    the mysql_error() function.

    Afterwhich, you can use the list of error codes from the MySQL website to
    map the error code to whatever you like.


    JW


    Comment

    • Janwillem Borleffs

      #3
      Re: Display server error

      Janwillem Borleffs wrote:[color=blue]
      > Sure, you can suppress the error message by preprending an at sign
      > "@" to the mysql_* function call and get the error code from the
      > string returned by the mysql_error() function.
      >[/color]

      That should be: the mysql_errno() function.


      JW


      Comment

      • Jerry Stuckle

        #4
        Re: Display server error

        Bob Sanderson wrote:[color=blue]
        > Is there a way, using PHP, to detect and display an error from a MySQL
        > server? Can I, by using error numbers or some similar method, create my own
        > error messages?
        >
        > tia[/color]

        You can get the MySQL error number with mysql_errno() and the text with
        mysql_error(). Then just display whatever text you wish.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...