Can not send any variable with the ehternet shield

Hello everyone,

I just got my new arduino Ethernet shield, i bought this one: http://store.arduino.cc/eu/index.php?main_page=product_info&cPath=11_5&products_id=199
I also got an arduino mega 2560.

Just tried the example project with the Ethernet shield and i am getting information back from Google, just to test.
Now i would like to send some variables to my php file on my website.

Here is a little code i make to test it:

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

byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
char serverName[] = "www.website.com";

EthernetClient client;

void setup()
{
  Serial.begin(9600);
  Serial.println("Starting up the board");
  
  Serial.print("Starting up ehternet");

  Ethernet.begin(mac);
  
  Serial.println("....Done");
}


void loop()
{
  unsigned long currentMillis = millis();
  
  if(currentMillis < previousMillis)
  {
    previousMillis = 0;
  }
  
  if(currentMillis - previousMillis2 > interval2) 
  {
    previousMillis2 = currentMillis;
    Serial.print("Connecting to website...");
    
    if (client.connect(serverName, 80)) {
      Serial.println("connected");
      
      client.println("GET /meterstand.php?meter1=1 HTTP/1.1");
      client.println();
      client.println();
      
      Serial.println("Disconnecting");
      client.stop();
    }
    else
    {
      Serial.println("could not connect");
    }
    
  }

It says it’s connected and disconnected but when i look into my database it’s empty.
When i use the url in my browser everything works just fine.

I hope someone could help me because i already looked at the forum and tried several things but it does not work for me.

When you request data from a server, using the GET function, is it not reasonable to expect a response? Why are you ignoring any response?

If you were to actually read the response, perhaps a clue-by-four would whack you.

I found what the problem was, i did not use http://

I do not have to get some information from the server, i only want to send data to it to put into the sql database.

I do not have to get some information from the server, i only want to send data to it to put into the sql database.

That may be, but the server is going to return information anyway, especially in the event of a failure to communicate. You should, at least in the beginning, read that response, to confirm that things are working as intended.

Ah okey i understand, what is the best way to see if it's working right?

what is the best way to see if it's working right?

Gee, I don't know. Maybe read the response from the server.

I think Paul is correct. Try something like this:

    if (client.connect(serverName, 80)) {
      Serial.println("connected");
      
      client.println("GET /meterstand.php?meter1=1 HTTP/1.1");
      // send host url for virtual servers
      client.print("Host: ");
      client.println(serverName);
      // tell server to close when finished with HTTP/1.1
      client.println("Connection: close");
      client.println();

      while(client.connected())
      {
         // server will close the connection when finished
         // but the connection will not close until the rx buffer is empty
         while(client.available())
         {
            Serial.write(client.read());
         }
      }
      
      Serial.println("Disconnected");
      client.stop();

edit: added host for virtual servers.