Ethernet Shield Problem with Sending Value to Localhost database

Bonjour a tous ,
s'il vous plait qui peut m'aider je suis débutant sur arduino et je travaille sur un projet en utilisant ethernet shield et wamp server :
envoyer les valeurs de capteur de température vers base de donnée !
mais j'ai rencontré un problème dans la moniteur série s'affiche tous les valeur mais dans la base aucun valeur ajouter
ps: lorsque j'ajout une valeur avec lien localhost est bien marché !

code arduino
#include <SPI.h>
#include <Ethernet.h>
#include "lm35.h"
#define LM35PIN 0
#define lm35
#define LM35TYPE lm35

byte mac[] = { "0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED" };
byte ip[] = {"169, 254, 30, 136" }; //Enter the IP of ethernet shield
byte serv[] = {"192, 168, 137, 107"} ; //Enter the IPv4 address
EthernetClient cliente;
float temp;
int tempPIN= 0;

void setup() {
Serial.begin(9600); //setting the baud rate at 9600
Ethernet.begin(mac, ip);

}

void loop() {
temp=analogRead(tempPIN);
if (cliente.connect(serv, 80)) { //Connecting at the IP address and port we saved before
Serial.println("connected");
cliente.print("GET /ethernet/connection.php?"); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);

//Printing the values on the serial monitor
Serial.print("Temperature= ");
Serial.println(temp);

cliente.stop(); //Closing the connection
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
delay(5000);
}

cliente.print("GET /ethernet/connection.php?"); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);

A GET request ends with " HTTP/1.0" or " HTTP/1.1". If you use the 1.1 version, you need to add a Host header, too.

no , it's not working :frowning:
what's the host if i use local wamp server ?

and it's necessary use internet with localhost !

what's the host if i use local wamp server ?

PM me. I'll send you a mailing address. You mail me your server, and I'll type ipconfig in a command window, and send you back the result. If you include a return label, and return postage, I'll send your computer back to you.

and it's necessary use internet with localhost !

The name "localhost" is used when the client and the server are the same machine. I'm almost certain that there is not a AAMP (Arduino, Apache, MySQL, PHP) package available. So, you are NOT using localhost.

You need a minimum of two computers with ethernet capability and a router. One of them will be the Arduino, of course. The router does not have to be connected to the internet.

ok but the code does'nt send any data to the data base

look to this code i don't know what the problm why didn't send the data please help me

#include <SPI.h>
#include <Ethernet.h>

#include "lm35.h"
#define LM35PIN 0
#define LM35
#define LM35TYPE lm35

#include "ACS712.h"
#define acsPIN 1
#define ACS712

#include "ZMPT101B.h"
#define zmpt101bPIN 2
#define ZMPT101B

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192 , 168 , 1 , 101 }; //Enter the IP of ethernet shield
byte serv[] = { 192 , 168 , 1 , 100 } ; //Enter the IPv4 address
EthernetClient cliente;
float temp;
int tempPIN= 0;

float courant;
int courantPIN=1;

float tension;
int tensionPIN=2;
double sensorValue=0;
double sensorValue1=0;
int crosscount=0;
int climbhill=0;
double VmaxD=0;
double VeffD;
double Veff;

#define pin_courant A1
#define pin_tension A2

void setup() {
Serial.begin(9600); //setting the baud rate at 9600
Ethernet.begin(mac, ip);

}

void loop () {
String data ;
temp=analogRead(tempPIN);
temp= (5.0 * temp * 100.0)/1024.0;

float average=0;
for (int i=0; i < 1000; i++)
( courant = average + (.044*analogRead(A1) -3.78)/1000);

sensorValue1=sensorValue;
delay(100);
sensorValue = analogRead(A0);
if (sensorValue>sensorValue1 && sensorValue>511){
climbhill=1;
VmaxD=sensorValue;
}
if (sensorValue<sensorValue1 && climbhill==1)
{ climbhill=0;
VmaxD=sensorValue1;
VeffD=VmaxD/sqrt(2);
Veff=(((VeffD-420.76)/-90.24)*-210.2)+210.2;
Serial.println(Veff);
VmaxD=0;}

if (cliente.connect(serv,8080)) { //Connecting at the IP address and port we saved before
Serial.println("connected");

cliente.println(" POST /ethernet/data.php? "); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);
cliente.print("courant=");
cliente.print(courant);
cliente.print("tension=");
cliente.print(tension);
cliente.println(" HTTP/1.1\r\n");
cliente.print("Host: www.display.com\r\n ");
cliente.println ();
cliente.println ();
//Printing the values on the serial monitor
Serial.print("Temperature= ");
Serial.println(temp);
Serial.print("courant= ");
Serial.println(courant);
Serial.print("Tension= ");
Serial.println(tension);

cliente.stop(); //Closing the connection
}
else {
// if you didn't get a connection to the server:
Serial.println(" Connection failed");
}
delay(5000);
}

  float average=0;
  for (int i=0; i < 1000; i++)
   ( courant = average + (.044*analogRead(A1) -3.78)/1000);

That is not averaging 1000 readings.

cliente.println(" POST /ethernet/data.php? "); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);
cliente.print("courant=");
cliente.print(courant);
cliente.print("tension=");
cliente.print(tension);
cliente.println(" HTTP/1.1\r\n");

There is no space after the ?. Name=value pairs are separated by &.

Why are you using POST when you send all the data in the request?

 cliente.print("Host: www.display.com\r\n ");

Is that really the name of the host?

Since you have access to the server, since it is in your local area network, look at the server logs. What is happening? Does the data.php script actually exist? In the ethernet directory of the server root?

the new code but doesn't work i don't know what the problem

#include <SPI.h>
#include <Ethernet.h>
#include "lm35.h"
#define LM35PIN 0
#define lm35
#define LM35TYPE lm35

#include "ACS712.h"
#define acsPIN 1
#define ACS712

#include "ZMPT101B.h"
#define zmpt101bPIN 2
#define ZMPT101B

float temp;
int tempPIN= 0;

float courant;
int courantPIN=1;

float tension;
int tensionPIN=2;
double sensorValue=0;
double sensorValue1=0;
int crosscount=0;
int climbhill=0;
double VmaxD=0;
double VeffD;
double Veff;

#define pin_courant A1
#define pin_tension A2

byte mac[] = { "0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED" };
byte ip[] = {"169, 168, 1, 101" }; //Enter the IP of ethernet shield
byte serv[] = {"192, 168, 1, 100"} ; //Enter the IPv4 address
EthernetClient cliente;

void setup() {
Serial.begin(9600); //setting the baud rate at 9600
Ethernet.begin(mac, ip);

}

void loop() {
temp=analogRead(tempPIN);
if (cliente.connect(serv, 8080)) { //Connecting at the IP address and port we saved before
Serial.println("connected");
cliente.print("GET /ethernet/connection.php ? HTTP/1.0"); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);
cliente.print("courant=");
cliente.print(courant);
cliente.print("tension=");
cliente.print(tension);

//Printing the values on the serial monitor
Serial.print("Temperature= ");
Serial.println(temp);
Serial.print("courant= ");
Serial.println(courant);
Serial.print("Tension= ");
Serial.println(tension);

cliente.stop(); //Closing the connection
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
delay(5000);
}

cliente.print("GET /ethernet/connection.php ? HTTP/1.0"); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);
cliente.print("courant=");
cliente.print(courant);
cliente.print("tension=");
cliente.print(tension);

Pay some f**king attention. The HTTP/1.0 bit goes AT THE END!

The name = value pairs are separated by &s.

There are NO spaces before the ? or after it/

cliente.print("GET /ethernet/connection.php?"); // No useless comment needed
cliente.print("temperature=");
cliente.print(temp);
cliente.print("&");
cliente.print("courant=");
cliente.print(courant);
cliente.print("&");
cliente.print("tension=");
cliente.print(tension);
cliente.println(" HTTP/1.0");

Do NOT say "it doesn't work" again. The code does SOMETHING. You expect it to do something. Tell us what those two somethings are and how they differ.

Show us the log file(s) from the server.