Novak007 Novak007 - 4 years ago 91
C Question

Inserting in MySQL Table

I am trying to insert data into mysql table through mysql C client, through the step written below.

The command is of the Form : (A variable string generated at run time)

INSERT INTO department values('Statistics','Taylor',395051.74)

which is correct for MySQL.

if (mysql_query(con, command))


But my database shows no change. No rows get inserted, is there any way the above steps could not work?

Answer Source

Note that mysql_query returns a zero if it is successful, and an error code if it's unsucessful MySQL Docs. I think you might be treating it backward. So I think it's issuing an error you're not catching.

As a guess of what might be wrong, try telling it what columns you're inserting into:

INSERT INTO department (`column1`,`column2`,`column3`) 
values ('Statistics','Taylor',395051.74)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download