error handling for mysql_query

Discussion in 'PHP' started by daboss, Aug 29, 2006.

  1. #1
    i'm not sure why this is not working on my set up:

    $sql = "select * from table [COLOR="Red"][B]XXXXX[/B][/COLOR]";
    $rst = mysql_query($sql);
    
    if(!rst) {
      print "<br>Error: " . mysql_error() . "<br><br>";
    }
    else {
      print "Success!";
    }
    Code (markup):
    the sql syntax is obviously wrong but somehow the condition (!rst) never returns true - i.e. i always get "Success" displayed...

    anyone know if there are any settings i need to set up or change in my php.ini file? or what's the reason behind this?
     
    daboss, Aug 29, 2006 IP
  2. hextraordinary

    hextraordinary Well-Known Member

    Messages:
    2,171
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    105
    #2

    change:
    to:

     
    hextraordinary, Aug 29, 2006 IP
    daboss likes this.
  3. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it's confirmed - i'm getting old and blind... :D

    thanks a million - i have been sitting here looking at the damn thing for hours... some green on its way...
     
    daboss, Aug 29, 2006 IP
  4. hextraordinary

    hextraordinary Well-Known Member

    Messages:
    2,171
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    105
    #4
    Happens to everyone.... If I only counted the lost hours...
     
    hextraordinary, Aug 29, 2006 IP