mysql null

Posted on 2005-05-07
Last Modified: 2010-04-01
this is my code:

                MYSQL *conn;
      MYSQL_RES *res;
      MYSQL_ROW  row;
      query = query1 + me->id;

      conn = mysql_init(NULL);
      mysql_real_connect(conn, "", "", "", "", 0, NULL, 0);
      mysql_query(conn, query.c_str());
      res = mysql_store_result(conn);
      while(row = mysql_fetch_row(res))
   = row[0];
   = "";
            user.session = "";
            user.socket = -1;
            user.sequence = row[1];

I want to check if row[1] is a mysql null, how do I do that?
Question by:Buffon
    LVL 55

    Expert Comment

    by:Jaime Olivares
    just have to check if empty:

    if (!strlen(row[1])) {
       // it is empty or null
    LVL 11

    Author Comment

    and what if I want to distinguish between empty and null?
    LVL 55

    Accepted Solution

    According with MySql documentation:
    null values are returned as null pointers, so this will be different to my first code:

    if (row[1]==NULL) {
       // it is null

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
    Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now