Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    124
    Thanks
    7
    Thanked 0 Times in 0 Posts

    mysql_result and <NULL>

    so, i want to grab the value of a sql entry. but the thing is, sometimes this value is <NULL>. i thought, no biggy, i'll just have an if statement:
    PHP Code:
    if (is_numeric(mysql_result($query0))) {
        
    //do something
    } else {
        
    //do something else using  mysql_result($category_id_query, 0);

    however, this doe not work. i get this error:
    Code:
    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3
    is there a way to check to see if mysql_result() is <NULL> without throwing an error??

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Use the MySQL function ISNULL().

  • #3
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi you could use also php functions to check mysql result
    mysql_num_rows
    or
    mysql_affetched_rows
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Posts
    124
    Thanks
    7
    Thanked 0 Times in 0 Posts
    awesome, thanks, mysql_num_rows worked. the problem with is_numeric or is_null is that mysql_result would throw the error no matter what. using mysql_num_rows let me check to see if there was anything in it before using mysql_result


  •  

    Posting Permissions

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