Transfer RFID-tag nicht. zu mysql

Ich habe harte Zeit zu übertragen RFID-tag nicht. auf die mysql-Datenbank. Wenn ich kompilieren Sie den gegebenen code-server bekommt so angeschlossen und druckt die rfid-Nr. und sagt auch Daten zum server gesendet wird, aber wenn ich meine php Datei (auch mysql) es gibt keine Daten gespeichert. Was mache ich falsch!! P. s sorry für mein schlechtes Englisch.

#include <Ethernet.h>
#include <SPI.h>
#include <Client.h>
#include<SoftwareSerial.h>
SoftwareSerial RFID(2,3);
int i;
int rfid;
char newtag[14];//= {2,49,51,48,48,57,69,66,48,51,57,48,52,3};
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte subnet[] = {255,255,255,0};
//IPAddress gateway(192,168,1,1);
//IPAddress DBserver(192, 168, 1, 2);
IPAddress server(192,168,1,7);
//char server[] = "localhost/te";
IPAddress ip(192,168,1,2);
EthernetClient client;
void setup()
{
    Serial.begin(9600);
    RFID.begin(9600);
    delay (1000);
    Serial.print("*********Initializing Ethernet*********n");
    if (Ethernet.begin(mac) == 0)
    {
        Serial.println("Failed to configure Ethernet using DHCP");
        Ethernet.begin(mac, ip);
    }
    //Ethernet.begin(mac, server, gateway);
    delay(1000);
    Serial.println("connecting...");
    Serial.print("IP Address:");
    Serial.println(Ethernet.localIP());
    Serial.print("Subnet Mask:");
    Serial.println(Ethernet.subnetMask());
    Serial.print("Default Gateway IP:");
    Serial.println(Ethernet.gatewayIP());
    Serial.print("DNS Server IP:");
    Serial.println(Ethernet.dnsServerIP());
}
void loop()
{
    //while(1)
    {
        if (client.connect(server, 80))
        {
            Serial.print("Connected to server:");
            Serial.println(Ethernet.dnsServerIP());
            while(1)
            {
                if (RFID.available() > 0)
                {
                    Serial.println("reading rfid tags");
                    delay(100);
                    for (i=0; i < 14; i++)
                    {
                        rfid = RFID.read();
                        newtag[i]=rfid;
                    }
                    RFID.flush();
                    Serial.print("rfid tag no:");
                    Serial.print(newtag);
                    Serial.println("Sending to Server...");
                    client.println("GET 192.168.1.7/te/add_data.php?sensor=2323 HTTP/1.1");
                    client.print(newtag);
                    client.println(" HTTP/1.1");
                    client.println("Host: 192.168.1.7/te/");
                    client.println("User-Agent: Arduino");
                    client.println("Accept: text/html");
                    Serial.println("data sent to server");
                }
            }
        }
        else
        {
            Serial.println("Cannot connect to Server");
        }
    }

und mein php-code ist

<?php
    //Start MySQL Connection   
    include('dbconnect.php'); 
?>
<html>
<head>
    <title> Log</title>    
    <style type="text/css">    
        .table_titles, .table_cells_odd, .table_cells_even {    
                padding-right: 20px;    
                padding-left: 20px;    
                color: #000;    
        }    
        .table_titles {    
            color: #FFF;    
            background-color: #666;    
        }    
        .table_cells_odd {    
            background-color: #CCC;    
        }    
        .table_cells_even {    
            background-color: #FAFAFA;    
        }    
        table {    
            border: 2px solid #333;    
        }    
        body { font-family: "Trebuchet MS", Arial; }    
    </style>    
</head>    
    <body>    
        <h1>Arduino  Log</h1>    
    <table border="0" cellspacing="0" cellpadding="4">    
      <tr>
           <td class="table_titles">ID</td>    
            <td class="table_titles">Date and Time</td>
            <td class="table_titles">RFID tag</td>
      </tr>
<?php    
    //Retrieve all records and display them
    $result = mysql_query("SELECT * FROM FYP ORDER BY id ASC");
    //Used for row color toggle
    $oddrow = true;
    //process every record
    while( $row = mysql_fetch_array($result) )
    {
        if ($oddrow) 
        { 
            $css_class=' class="table_cells_odd"'; 
        }
        else
        { 
            $css_class=' class="table_cells_even"';

        }
        $oddrow = !$oddrow;
        echo '<tr>';
        echo '   <td'.$css_class.'>'.$row["id"].'</td>';
        echo '   <td'.$css_class.'>'.$row["event"].'</td>';
        echo '   <td'.$css_class.'>'.$row["tag"].'</td>';
        echo '</tr>';
    }
?>
    </table>
    </body>
</html>
  • Bitte korrigieren Sie den Einzug (und entfernen Sie alle leeren Zeilen). Bitte.
  • Das sieht aus wie C-code, läuft auf Ihre Arduino und implementiert einen sehr einfachen subset des HTTP-Protokolls. Ist das richtig? Ich denke, Ihr GET-Anfrage sollte enthalten weder Ihren host-ip-Adresse. Ich denke, es ist möglich, Ihre php-Programm nie getroffen wird, weil die.
  • was soll ich schreiben, in-Stelle BEKOMMEN Sie dann!!!
  • Haben Sie uns gezeigt, wie der code für te/add_data.php? Ich kann nicht finden, den Ort, wo Sie akzeptieren die Daten vom arduino in den code, den Sie eingerichtet haben.
InformationsquelleAutor bip_123 | 2014-12-12
Schreibe einen Kommentar