how to send information through rfid to mysql database without php

Hello guys ,

We re trying to send card id informations to mysql database by using RC522 RFID Reader. We stored our card IDs as a byte array (ie byte cardID[]={255,10,8,142}) We cannot insert that variable into our database with using that library (attachment). We do not want to use php (get request). We are waiting for advices , how can we send to card IDs to mysql database please help us... Our codes :

/**


  • This is a MFRC522 library example; see GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522
  • for further details and other examples.
  • NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
  • Released into the public domain.

  • This sample shows how to read and write data blocks on a MIFARE Classic PICC
  • (= card/tag).
  • BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7).
  • Typical pin layout used:

  • MFRC522 Arduino Arduino Arduino Arduino Arduino
  • Reader/PCD Uno Mega Nano v3 Leonardo/Micro Pro Micro
  • Signal Pin Pin Pin Pin Pin Pin

  • RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
  • SPI SS 1 SDA(SS) 10 53 D10 10 10
  • SPI SS 2 SDA(SS) 2 53 D10 10 10
  • SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
  • SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
  • SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15

*/

/*
MySQL Connector/Arduino Example : complex insert

This example demonstrates how to issue an INSERT query to store data in a
table using data from variables in our sketch. In this case, we supply the
values dynamically.

This sketch simulates storing data from a sensor in a table.

For this, we will create a special database and table for testing.
The following are the SQL commands you will need to run in order to setup
your database for running this sketch.

Here we have a table that contains an auto_increment primary key, a text
field, a field to identify the sensor, the value read, and timestamp of
the recorded data.

Note: Since this sketch uses test data, we place the INSERT in the setup()
method so that it runs only once. Typically, you would have the
INSERT in the loop() method after your code to read from the sensor.

INSTRUCTIONS FOR USE

  1. Create the database and table as shown above.
  2. Change the address of the server to the IP address of the MySQL server
  3. Change the user and password to a valid MySQL user and password
  4. Connect a USB cable to your Arduino
  5. Select the correct board and port
  6. Compile and upload the sketch to your Arduino
  7. Once uploaded, open Serial Monitor (use 115200 speed) and observe
  8. After the sketch has run for some time, open a mysql client and issue
    the command: "SELECT * FROM test_arduino.hello_sensor" to see the data
    recorded. Note the field values and how the database handles both the
    auto_increment and timestamp fields for us. You can clear the data with
    "DELETE FROM test_arduino.hello_sensor".

Note: The MAC address can be anything so long as it is unique on your network.

Created by: Dr. Charles A. Bell
*/
#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9 //Reset pini tanýmlanmasý
#define SS_1_PIN 2 //SS1 pini tanýmlanmasý
#define SS_2_PIN 3 //SS2 pini tanýmlanmasý
#define SS_3_PIN 5 //SS3 pini tanýmlanmasý
#define SS_4_PIN 6 //SS4 pini tanýmlanmasý
#define SS_5_PIN 7 //SS5 pini tanýmlanmasý
int ssPins [] = {SS_1_PIN, SS_2_PIN, SS_3_PIN, SS_4_PIN, SS_5_PIN}; //ssPins arrayinin oluþturulmasý ve tanýmlanmasý
#define NR_OF_READERS 5 //for döngüsü için okuyucu sayýsýnýn tanýmlanmasý

String kartID;

MFRC522 okuyucu[5]; //okuyucular için array oluþturulmasý

byte kartNumarasi[4]; //kart numarasýný yazdýrabilmek için gerekli arrayin oluþturulmasý

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr(192,168,2,156); // IP of the MySQL server here
char user[] = "arduino"; // MySQL user login username
char password[] = "password"; // MySQL user login password

// Sample query
char INSERT_DATA[] = "INSERT INTO deneme_db.tumkisi (kartno) VALUES (%s)" ;
char query[128];

EthernetClient client;
MySQL_Connection conn((Client *)&client);

void setup() {
Ethernet.begin(mac_addr);
SPI.begin(); // SPI bus'ýn baþlatýlmasý
Serial.begin(115200); // Seri iletiþimin baþlatýlmasý
while (!Serial); // Seri iletiþim yoksa bir þey yapma

conn.connect(server_addr, 3306, user, password);
delay(1000);

for (int i = 0; i < NR_OF_READERS; i++) {
okuyucu.PCD_Init(ssPins*, RST_PIN); // Her kart okuyucunun tanýtýlmasý*
* }*

}
void loop() {
* for (int i = 0; i < NR_OF_READERS; i++) { //Her bir kart okuyucuyu kontrol edecek olan for döngüsü*
* kartID = "";*
* byte bufferATQA[10]; //Answer to quest arrayinin oluþturulmasý*
* byte bufferSize[10]; //bufferSize arrayinin oluþturulmasý*
okuyucu*.PICC_WakeupA(bufferATQA, bufferSize); //kart okuyucuyu idle modundan active moda geçirilmesi*
* //delay(500);*
if ( okuyucu*.PICC_ReadCardSerial()) { //yeni bir kart varsa ve kart numarasý okunuyorsa*

* Serial.print(i); //kart okuyucu numarasý*
* Serial.print(F(" Numarali okuyucudan: "));*

_ for (int j = 0; j < okuyucu*.uid.size; j++) { //kart numarasýnýn alýnmasý için for döngüsü oluþturulmasý*
kartNumarasi[j] = okuyucu*.uid.uidByte[j]; //kartnumarasý arrayinin oluþturulmasý ve elemanlarýnýn atanmasý.
kartID += kartNumarasi[j]; //kart numarasýnýn ekrana bastýrýlmasý*

* }
Serial.println(kartID);*_

* // Initiate the query class instance*
MySQL_Cursor cur_mem = new MySQL_Cursor(&conn);
_ // Save*_

* sprintf(query, INSERT_DATA, kartID);
_ // Execute the query*
* cur_mem->execute(query);*
* // Note: since there are no results, we do not need to read any data*
* // Deleting the cursor also frees up memory used*
* delete cur_mem;*
* Serial.println("Data recorded.");*_

* // Halt PICC*
okuyucu*.PICC_HaltA();
_ // Stop encryption on PCD*_

okuyucu*.PCD_StopCrypto1();*

* }*

}

}
THANK YOU VERY MUCH

THANK YOU VERY MUCH

For posting your code all wrong. Where are the code tags, to keep the forum software from mangling it?

The code you posted does something. You did not explain what it actually does.

sprintf(query, INSERT_DATA, kartID);

The INSERT_DATA array contains:

INSERT INTO deneme_db.tumkisi (kartno) VALUES (%s)

The only format specifier in there is %s, which is the format specifier for a string. kartID is NOT a string.

Ditch the String class. Make kartID a string.

The simple answer to the question in the title would be to use Python, Ruby, C++ or any other language as an alternative to PHP.

...R