segmentation fault with c++ after mysql_fetch_row
Posted by: Gary Finnegan
Date: July 15, 2010 11:09AM

Hello Everyone,
I am hoping that someone knows what is going on. I am using mysql.h with c++ and have the following code snippet:

while ( 1 ) {
cout << mysql_num_rows(result) << " = ROWS" << endl;
if(mysql_fetch_row(result)==NULL){cout << "IM BREAKING" << endl; break;}
row=mysql_fetch_row(result);
string temp11=row[0];
cout << temp11 << endl;
// name.push_back(row[0]);
}
}

If the number of rows is equal to 1 then when I try to do row[0] to get the first element in the row, I get a seg fault. If the number of rows i greater than 1, the code works fine. Any thought?
Thank,
Gary Finnegan

Options: ReplyQuote


Subject
Views
Written By
Posted
segmentation fault with c++ after mysql_fetch_row
2512
July 15, 2010 11:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.