Problem in transfer data from arduino to Mysql database using ethernet shield

Please help me master :slight_smile:

i have got a problem in transferring data from arduino uno to Mysql database (i am using php)
i use ethernet shield to transfer data from client to server
i’m using Xampp, i have local network … no internet connection.

according to this link: http://thegeekforge.com/index.php?/archives/4-Arduino-Ethernet,-POST-to-PHP-to-MySQL.html

Here is my project :

  1. update.php
<?php 
require("config.php");
// You need to create a table on your MySql server database. Here it is called 'MY_TABLE'.
              // You will also have to define fields in the table.
             //I happen to name my fields the same as my POST variables.


$query = "INSERT INTO monitoring(irms1,irms2,irms3) 
                  VALUES('$_POST[irms1]', '$_POST[irms2]', '$_POST[irms3]')";


 if(!@mysql_query($query))
{
echo "&Answer; SQL Error - ".mysql_error();
 return;
}
?>
[/code

2. config.php
[code]
<?php

$dbhost = 'localhost'; 
$dbuser = 'root';    
$dbpass = ''; 
$dbname = 'edwin'; 

$query = "INSERT INTO monitoring(irms1,irms2,irms3) 
                  VALUES('$_POST[irms1]', '$_POST[irms2]', '$_POST[irms3]')";

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');  
mysql_select_db("edwin");
}
?>
  1. arduino sketch
#include <SPI.h>
#include <Ethernet.h>

int irms1; 
int irms2;
int irms3;


String txData ="";


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

byte ip[]      = { 192,168,1,9 }; 
byte gateway[] = { 192, 168,   3,  1 }; 
byte subnet[]  = { 255, 255, 255,   0 }; 



void setup()
{
  
  Ethernet.begin(mac, ip);

 Serial.begin(9600); 
 delay(1000);
}
void loop()
{ 
  irms1 = analogRead(A0);
  irms2 = analogRead(A1);  
  irms3= analogRead(A3);
  

 txData = "i1="+ (String (irms1)) + "i2="+ (String (irms2)) + "i3="+ (String (irms3));

                                            
 EthernetClient client;

 

if (client.connect("192.168.1.100",80))
  {

    Serial.println("Connected to server..."); 
Serial.println();

                                               

 client.print("POST /update/update.php HTTP/1.1\n");

                                            

 client.print("Host: server\n");                          
   client.print("Connection: close\n");

   client.print("Content-Type: application/x-www-form-urlencoded\n");
   client.print("Content-Length: ");

              

client.print(txData.length());                                            
   client.print("\n\n");
    client.print(txData);    
 }
  else
 {
   Serial.println("Connection Failed."); 
 Serial.println();
}
 delay(5000); 
}

screenshot of serial monitor

https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F2.bp.blogspot.com%2F-zcxYQUgG994%2FU4QBL8FwqjI%2FAAAAAAAAByU%2FvHzprhy_SXo%2Fs1600%2F1.bmp&container=blogger&gadget=a&rewriteMime=image%2F*

the database of mysql dont update

Please help me XD
[/code]

The first thing I see is you forgot the ampersands (&) in the POST data.

 txData = "i1="+ (String (irms1)) + "&i2="+ (String (irms2)) + "&i3="+ (String (irms3));

the database of mysql dont update

The server generates some kind of reply. Why are you not reading that? A clue just might present itself.