mysql and arduino

Hi all,

Iam testing with a local mysql database called door and table tag with column id and trying to find in that column the string 5D2249AD8D. The following code works fine but when i try to replace 5D2249AD8D with id[0] that seems to fail. Any help???

#include <SPI.h>
#include <Ethernet.h>
#include <sha1.h>
#include <avr/pgmspace.h>
#include <stdlib.h>
#include <mysql.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(xxx,xxx,xxx,xxx);
IPAddress ip(xxx,xxx,xxx,xxx);
char user[] = "xxx";
char password[] = "xxx";

Connector my_conn;        

void setup() 
{
  Ethernet.begin(mac_addr,ip);
  Serial.begin(9600);
  Serial.println("Connecting...");
 
  if (my_conn.mysql_connect(server_addr, 3306, user, password)) 
  {
    delay(1000);
    const char QUERY_POP[] = "SELECT id FROM door.tag WHERE id = '5D2249AD8D'";
    my_conn.cmd_query(QUERY_POP);
    my_conn.show_results();
  }
  else
    Serial.println("Connection failed.");
}

void loop() 
{
}
char* id[]={"5D2249AD8D"};
const char QUERY_POP[] = "SELECT id FROM door.tag WHERE id = 'id[0]'";

I would use sprintf for this.

char QUERY_POP[64];

sprintf(QUERY_POP,"SELECT id FROM door.tag WHERE id = '%s'",id);
Serial.println(QUERY_POP);

You could also use strcat.

char QUERY_POP[64] = "SELECT id FROM door.tag WHERE id = '";
strcat(QUERY_POP,id);
strcat(QUERY_POP,"'");
Serial.println(QUERY_POP);