MySQL C API mysql_query
NickName:jakeheik90 Ask DateTime:2015-09-11T18:38:46

MySQL C API mysql_query

I have two problems with the MySQL C API. How do I get variable to be added to the table when I do the mysql_query() and how do I get the table show decimals?

Here is my code:

void insertDataToTable(MYSQL* con, float temp, int k)
{
    mysql_query(con, "INSERT INTO Weatherstation VALUES(@k,'Temperature:', @temp)");
}

Thank you!

Copyright Notice:Content Author:「jakeheik90」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/32521477/mysql-c-api-mysql-query

Answers
asio_guy 2015-09-11T10:42:47

Try this\n\nvoid insertDataToTable(MYSQL* con, float temp, int k)\n{\n char query[255] ;\n\n sprintf( query, \"INSERT INTO Weatherstation VALUES(%ld,'Temperature:', %d)\", temp, k );\n mysql_query(con, query );\n\n\n}\n",


More about “MySQL C API mysql_query” related questions

MySQL C API mysql_query

I have two problems with the MySQL C API. How do I get variable to be added to the table when I do the mysql_query() and how do I get the table show decimals? Here is my code: void insertDataToT...

Show Detail

$c = mysql_num_rows(mysql_query($q));

I was wondering if this $c = mysql_num_rows(mysql_query("select * from action_6_weekly where code='$code'")); is considered valid PHP? Or do I need to do the following? $r = mysql_query("select

Show Detail

MYSQL : problem with mysql_query

I need your help. What does this mean? Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\THESIS\

Show Detail

Concatenating mysql_query in C

I am getting user input from my C program and I want to use the user input in my SELECT statement. However the mysql_query() only has accepts two parameters. I was thinking of coding it like this...

Show Detail

Why does mysql_query() print an error?

I am just starting with C and the MySQL C API. I am using mysql_query() to create a table. According to the manual, the function usage is int mysql_query(MYSQL *mysql, const char *stmt_str), and the

Show Detail

load mysql dump in database using mysql C API

I want to manage a database in C language. So I am using C API for mysql. I am unable to find a function in C API for loading the a .sql file directly to mysql. I have gone through documentation bu...

Show Detail

MySQL C API custom values

I have been working with the tutorial on MySQL C API from http://zetcode.com/tutorials/mysqlcapitutorial/ the following example is working fine: #include <my_global.h> #include <mysql.h&g...

Show Detail

mysql c api limit function

mysql_query(conn,"SELECT abstract FROM papers limit 4 "); Can we use variables in limit function in C-api.Like I have to iteratively extract 10 rows,so something of the form: mysql_query(conn,"

Show Detail

mysql_query and embarcadero c++

I use MySQL C API with Embacadero c++ without any problems in (ANSI). But when I try to send any wide character (UNICODE) like Arabic symbols, appears as not readable characters (garbage) in MySQL

Show Detail

what is return error value of mysql_query in C?

folks, from the following code int a = mysql_query(conn,"INSERT into data VALUES (NULL,'tes','aja')); how come i could make sure mysql_query is do the supposed thing, because i've tried wrong sql

Show Detail