SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Every once in a while, my MySQL server hiccups and doesn't return a few of the queries on the page. Then it shows those big ugly warnings, which I don't want my visitors to see.

    Would it be possible to display a kind error message whenever the server hiccups telling the user to try again instead of seeing those ugly warning messages...

    I know how to put an error message in when the MySQL server doesn't respond at all, but when the server hiccups, about half of the queries are returned and half of them aren't.

    Thanks.

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you stick the @ sign in front of any function it supresses any error message going. You could try this for the mysql stuff:
    PHP Code:
    if (!$result = @mysql_fetch_result($sql))
         die (
    "A database error occurred."); 
    The same principle can be applied to your mysql_connect and mysql_select_db functions.

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I'm going to go put that in my code right now!

  4. #4
    Non-Member
    Join Date
    Apr 2000
    Location
    Waco, Texas.
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I usually do to handle warnings and errors with MySQL:

    PHP Code:
    <?
    $result 
    mysql_query("SELECT Foo from Bar") or die(mysql_error_msg());


    function 
    mysql_error_msg()
    {
        echo 
    "An error occured in the process:"mysql_error();
    }
    ?>
    Hope that helps.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •