Hallo
ich habe ein Arduino Board mit folgenden Datenbank Code
Die Datenbank habe ich so hinzugefügt zu phpmyadmin
Hoster ist www.freemysqlhosting.net
Ich bekomme immer den Fehler
Connecting...
Connected to server version 5.5.47-0ubuntu0.14.04.1
Query Success!
Error: 156 = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1.
Woher kann das kommen?
ich habe ein Arduino Board mit folgenden Datenbank Code
Code:
#include "SPI.h"
#include "Ethernet.h"
#include "sha1.h"
#include "mysql.h"
/* Setup for Ethernet Library */
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(52, 29, 239, 198);
/* Setup for the Connector/Arduino */
Connector my_conn; // The Connector/Arduino reference
int temperaturePin = 0;
char user[] = "sql7114427";
char password[] = "9ERf1KU11C";
void setup() {
Ethernet.begin(mac_addr);
Serial.begin(9600);
delay(10);
Serial.println("Connecting...");
if (my_conn.mysql_connect(server_addr, 3306, user, password))
{
Serial.println("Query Success!");
}
else
Serial.println("Connection failed.");
}
void loop() {
addTempEvent();
}
//taken straight from the adruino circ-10 example
float getVoltage(int pin){
//return (analogRead(pin) * .004882814);
return(1.0);
}
void addTempEvent()
{
//taken straight from the adruino circ-10 example
float temperature = getVoltage(temperaturePin);
//temperature = (((temperature - 0.5) * 100)*1.8) + 32; //Fahrenheit
temperature = (temperature - 0.5) * 100;
//I'm sure there is a cleaner way to build this string
char insert_sql[200] = "INSERT INTO sql7114427.temperature (id,temperature) VALUES (ID,";
dtostrf(temperature,1,2, &insert_sql[64]);
char* array3 = ")";
strcat(insert_sql,array3);
//Serial.println(insert_sql);
delay(5000);
my_conn.cmd_query(insert_sql);
delay(10000);
}
Die Datenbank habe ich so hinzugefügt zu phpmyadmin
Code:
CREATE TABLE `temperature` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`temperature` float DEFAULT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Hoster ist www.freemysqlhosting.net
Ich bekomme immer den Fehler
Connecting...
Connected to server version 5.5.47-0ubuntu0.14.04.1
Query Success!
Error: 156 = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1.
Woher kann das kommen?