Details
-
New Feature
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
3.1.9
-
None
-
None
-
raspianos GNU/Linux 10 on Raspberry pi 4a
Description
#include <mariadb/mysql.h>
.
.
.
float pHReading, TempReading;
.
.
.
if( tab_reg[0] > 64500 )
pHReading = ( (float)tab_reg[0] - 65535 ) / 100;
else
pHReading = (float)tab_reg[0] / 100;
printf( "Register 43001 pH = %.2f\n", pHReading );
.
.
.
TempReading = (float)(tab_reg[0])/10;
.
.
.
query = "insert into pHTemp values( NULL, NOW(), pHReading, TempReading )";
printf( "pHReading: %f and TempReading: %f and QUERY: %s\n", pHReading, TempReading, query );
if (mysql_real_query(mysql, query, strlen(query)))
show_error(mysql);
The resulting output and error are:
pHReading: 3.500000 and TempReading: 24.600000 and QUERY: insert into pHTemp values( NULL, NOW(), pHReading, TempReading )
Error(1054) [42S22] "Unknown column 'pHReading' in 'field list'"root@PiDevel:~/ModBus#
I cant seem to get the float vars pHReading and TempReading to dereference in the query before sending them to the DB
What am I doing wrong???
Richard