Hi all,
I am using mysql C API in my C++ project. I am using
mysql-4.1.4-gamma and gcc 3.2.2.
Problem with this code is that when add_data(i) is called second time
SEGMENTATION FAULT occurs at mysql_real_query(). First time it
executes the add_data() function successfully.
My Code is
MYSQL db is declared in main.cpp and database connection is also made
in main.cpp.
//main.cpp
add_carrier();
//carrier.cpp
add_carrier()
{
for(i=0;i<3;i++)
{
add_data(i);
}
}
//country.cpp
extern MYSQL db;
add_data(int i)
{
char sqlquery[500];
sprintf(sqlquery,"Select rateid from RATES where carrierid=%d",i);
//*** CAUSES SEGMENTATION FAULT WHEN add_data() IS CALLED SECOND
TIME
mysql_real_query(&db,sqlquery,strlen(sqlquery)); //SEGMENTATION
FAULT
...
...
...
}
Thanx in advance.
Regards,
Manpreet Dhanjal