mysql null

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))
      {
            user.id = row[0];
            user.name = "";
            user.session = "";
            user.socket = -1;
            user.sequence = row[1];
            me->q.push_back(user);
      }

I want to check if row[1] is a mysql null, how do I do that?
LVL 11
BuffonAsked:
Who is Participating?
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
According with MySql documentation:
http://sunsite.mff.cuni.cz/MIRRORS/ftp.mysql.com/doc/en/mysql_fetch_row.html
null values are returned as null pointers, so this will be different to my first code:

if (row[1]==NULL) {
   // it is null
}
0
 
Jaime OlivaresSoftware ArchitectCommented:
just have to check if empty:

if (!strlen(row[1])) {
   // it is empty or null
}
0
 
BuffonAuthor Commented:
and what if I want to distinguish between empty and null?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.