Hi all
I'm creating application which user input has to be inserted into mysql table through variables
So i'm just providing that instance of code ....so just help me out.
int get_basic_info() //defining function to getting a student's basic information
{
student_basic_info: //creating label for goto statement if user didn't enter the basic info it will repeat itself
cout<<"Student name :"<<student_name<<"\n";
cout<<"Student roll no :"<<enroll_no<<"\n";
cout<<"student branch :"<<student_branch<<"\n";
MYSQL *connect; //creating mysql connect pointer
connect=mysql_init(NULL);
if (!connect)
{
cout<<"MySQL Initialization failed";
return 1;
}
connect=mysql_real_connect(connect, "localhost", "root", "wildstone" ,
"student" ,0,NULL,0);
if (connect)
{
cout<<"\n\n";
cout<<"connected to database\n";
}
else
{
cout<<"\n";
cout<<"connection failed\n";
}
int query_state;
query_state=mysql_query (connect,"insert into student_record values('student_name','enroll_no','student_branch');"); //inserting values here but its not working.......
//
if(query_state)
{
cout<<"\n";
cout<<"Student's basic information successfully saved in database";
}
else
{
cout<<"\n";
cout<<"Problem occuring while saving information into database";
}
if(student_name!=0 && enroll_no!=0 && student_branch!=0)
{
cout<<"\n\n";
cout<<"Thank you for entering the basic information\n";
}