Results 1 to 3 of 3

Thread: [RESOLVED] Trap error and continue

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved [RESOLVED] Trap error and continue

    If $Field doesn't correspond to an actual field in my mySQL database I get an error. How can I trap if an error occurs (eg. ErrorFlag = True and then continue with the rest of the my code?

    PHP Code:
    $SQL "SELECT * FROM MyTable ORDER BY $Field";

    //Instead of die I want to trap error then continue
    $query mysql_query($SQL) or die("Error getting details<br>" .mysql_error()); 

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Trap error and continue

    PHP Code:
    $query = @mysql_query($SQL);
    if (
    mysql_errno()) {
      
    // do something...


  3. #3

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Trap error and continue

    Thanks penagate, will give it a go tomorrow at work.

Posting Permissions

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



Click Here to Expand Forum to Full Width