Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The C API and mysql

Status
Not open for further replies.

bonosa

Programmer
May 19, 2004
76
US
My first program . I have a three column table with entries in the first two and NULL in the third col.
I tried (from c++)

while( ( row = mysql_fetch_row(result) ) != NULL)
{
printf("id: %s,val: %s, name: %s\n",(row[0]?row[0]: "NULL"),(row[1]? row[1]:"NULL" ) ,(row[2]?row[2]: "NULL" ));
}

and its weird because I got
id: 1,val: A, name: ?


2
id: 2,val: A, name: 3
id: 3,val: C, name: 4
id: 4,val: B, name:
id: 5,val: B, name:
which is an exact view of what I see. I expected the word "NULL" to be there in the last column since I left that column blank.
ANy ideas why the value of row[2] is coming back with such odd values as 2, 3 when in actuality I put nothing in that column when I created the database.
Many thanks.
 
Maybe in your system, a NULL pointer is not represented by zero (it normally is, but I don't know if that's guaranteed). Maybe you could try instead:[tt]
(row[2]!=NULL?row[2]:"NULL")[/tt]


-----
ALTER world DROP injustice, ADD peace;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top