SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast dfysh's Avatar
    Join Date
    Jun 2004
    Location
    Maple Ridge,BC,CANADA
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy How do I check if a MySQL result set is NULL

    Good Day,

    I have a query that is producing no results as it is going against a table that may not have a row for the ID field I am searching on. That is all fine and running the query in Navicat I get back the results I expect.

    What I am not clear on is how to evaluate the results to decide if it is empty (NULL) or not. If the result set is empty than I want to display "no records found". If there is data than I want to parse it out (while($row = mysql_fetch_array($result_set)) {... ).

    Currently I am using:

    if(!$id) {
    echo "no records found";
    } else {
    echo "$id";
    }

    to evaluate if the record set has any values in it or not, but it is (of course) not working. I have tried several different ways of evaluating the $id variable but nothing seems to work (isset($id), == ' ', == NULL...). Anyone with any thoughts on what might be going on.

    When you have a moment.

    Best Regards

    Darcy

  2. #2
    Non-Member
    Join Date
    Aug 2002
    Location
    USA
    Posts
    544
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NULL won't be returned for results, only for fields, and would be the same thing as "empty".


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
  •