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
    New Coder
    Join Date
    Mar 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    equality for null from mysql

    How do I make a condition when a certain field of a mysql database is null. I tried empty($row['population']), !isset($row['population']), and $row['population'] == null. All of them don't work.

    PHP Code:
        $result mysql_query('SELECT city FROM town WHERE city="New York"');        
        
    $row mysql_fetch_array($result);
        
        
        
        if (empty(
    $row['population']))
    {
    .......

    EDIT: Found there is something wrong with my query!
    Last edited by Aonlan; 03-05-2008 at 03:15 AM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Well what is wrong with your query? To see if its null you can do
    PHP Code:
    if($row['population'] == NULL
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Well what is wrong with your query?
    Just a guess, but it might be that the field isn't selected. I wonder if that edit was intended to mean the OP solved it.

  • #4
    New Coder
    Join Date
    Mar 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yup, I solved it.

    The query did not select the field I want to check if it is null. But now I have another question. But I will put it in another thread.


  •  

    Posting Permissions

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