taking input from user
Posted by: JOY BANERJEE
Date: January 10, 2012 10:28AM

if we have to insert records into a mysql database using c api then the general code is this
if (mysql_query(conn, "insert into empinfo values ('saikat banerjee')")) 
  {
      printf("4Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
      exit(1);
  }
but, here we have to enter the record from the code itself .

but, i want to enter records from direct user inputs.
like, save the user input in a say, string variable and then use that string variable to store the record in the database. ie. i ant to do something like this
char empname[100]
and then,
if (mysql_query(conn, "insert into empinfo values (empname)")) 
  {
      printf("4Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
      exit(1);
  }
but, this is storing NULL in the table.

is there any way to do this?
please help!

Options: ReplyQuote


Subject
Views
Written By
Posted
taking input from user
1312
January 10, 2012 10:28AM


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.