Why Does it Work only sometimes????

hi there.
I have boiled the issue down to use the Arduino standard example.
Ihave this code.

arduino code:

/*
  Web client
 
 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen
 
 */

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "xxxxx.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,10,177);

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /kim.php?key=125 HTTP/1.1");
    client.println("Host: xxxxxcom");
    client.println("Connection: close");
    client.println();
  } 
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available 
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}

and here comes the PHP code:

$temp = $_GET["key"];

$filename = 'temperatures.csv';


define("LOG_FILE", "./temperatures.csv");

$file_handler = fopen(LOG_FILE, "a+");

fwrite($file_handler, time() . "," . $temp . "\n");
echo ok;

idea is to store data in a file, very simple.
but it does not function properly.

I have to resset the kit 3-5 times before it succeeded.
then it's ok 3-6 times but then again it does not work.

why is it not stable.
I have hosted at one.com

//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "xxxxx.com";    // name address for Google (using DNS)

Why are you too lazy to fix the clearly incorrect comments?

  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

And? You didn't feel it important to share this?

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }

If you do fail to connect, go into an infinite loop doing nothing. How can that POSSIBLY be what you want to do?

$filename = 'temperatures.csv';


define("LOG_FILE", "./temperatures.csv");

Why did you bother defining $filename?

echo ok;

I feel sorry for you, if you REALLY can't think of anything better to echo.

1 I would clearly not provide information about which domain I use.
2 no, I only need to send information.
3 No it's not what I want, I have used a standard Arduino example to make it easier for people to overview
4 yes i am a beginner
5 the ok is just to show that the php file works.

the question is will you help or do you just complain about how bad I am, I know that.

1 I would clearly not provide information about which domain I use.

Well, we KNOW that it is not google. If you change code and render a useless comment obsolete, don't just leave it there looking stupid. Banish useless comments to the bit bucket.

2 no, I only need to send information.

Well, get over it. If the server generates a response, you MUST read it. If you read it, and print it, it just might contain a clue. If it does, and you want help, you need to share the output.

3 No it's not what I want, I have used a standard Arduino example to make it easier for people to overview

That is not in my code. It is in your code. If it is not what you want, YOU should remove it.

5 the ok is just to show that the php file works.

Wouldn't echoing $temp or $filename do the same thing? Wouldn't you learn MORE from echoing one or both of them?

Thank you very helpful.
I find it hard to see that it would be going to do any difference.
php file works 100% I have tested using the web browser. everything works as expected.
the reading out c hmmm, I do not know if you've read the code but I get as an output on the serial monitor.

and that is the message, connect, connection failed, disconnect

when succes i get some lines that everything went well.

so I find it hard to understand your arguments. you would have a screnplot of it.
that you can get!

not ok c out:
connecting...
connection failed

disconnecting.

ok c out:

connecting...
connected
HTTP/1.1 200 OK
Date: Sun, 07 Sep 2014 14:24:05 GMT
Server: Apache
Content-Length: 2
Connection: close
Content-Type: text/html

ok
disconnecting.

hello when no one has any suggestions I'll come here with one.
I had the gut feeling and has now been confirmed.
my tery was that here was too much traffic on a web hotel.
I have to put my own server up and now it run as a dream.
I assume that there is some form of limitation to the web hotel I use.

someone who could make a comment to this theory

No one.???