Ethernet shield and get http protocol

Hi guys.I need some help.Using the ethernet shield am trying to send data to a database using a php script
Below is a part of my arduino code

EthernetClient client;

void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.println("starting simple arduino client test");
Serial.println();

delay(1000);

Serial.println("connecting...");

if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /~Documents/arduino.txt HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
}

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

if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================================");
Serial.println("");
client.stop();
for(;;);
}
}

am not able to read the arduino.txt file.
Can anybody help especially in the http get syntax
for the webserver am using apache

I use my own code. You might want to try it. Use the GET method example.
http://playground.arduino.cc/Code/WebClient

It is best if you post all your sketch code, not just sections.

Hi Karma.Thanks alot for your code.I have still not made any headways.
Here is my code

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

// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
byte ip[] = { 10,42,0,12 };
byte server[] ={ 10, 42, 0 ,1};
char strURL[70];

EthernetClient client;
void setup()
{
Ethernet.begin(mac,ip);
Serial.begin(9600);
//disabling spi
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);

delay(1000);
Serial.println("Connecting");

if (client.connect(server,80))
{
Serial.println("connected");
int temp = 75;
delay(50);
sprintf(strURL,"GET /project.php?t=%d",temp);
client.println(strURL);
client.println("HTTP 1.1");
client.println();
Serial.println(strURL);

//client.println("GET /localhost/arduino.txt HTTP/1.1");
}
else
{
Serial.println("connection failed ");
Serial.println(Ethernet.localIP());
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}

if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================================");
Serial.println("");
client.stop();
for(;;);
}
}

The project php is for displaying the data
If it does that ,it will assist me to further see how I can store the same information in a database
code for php is as follows

<?php echo $_GET['t']; ?>

But I must say that am still getting an error(404);
Can you please explain to me the get statement especially url part.
Thanks

Error 404 is "Page not found". Are you sure 10.42.0.1 is your server ip address? Normally, that ip is the gateway address (router). Try this from your web browser. Do you get the 404 error?
http://10.42.0.1/project.php?t=12

If you are sure that is correct, try this request.

    sprintf(strURL,"GET /project.php?t=%d HTTP/1.0\r\n",temp);
    client.println(strURL);
    Serial.println(strURL);

Thanks a lot.
It worked.
My question would be why does the escape sequence make such a difference? more so the \r "which I assume is the carriage return"

My question would be why does the escape sequence make such a difference?

It doesn't. You could do:

    sprintf(strURL,"GET /project.php?t=%d HTTP/1.0",temp);
    client.println(strURL);
    client.println();

Perhaps it was the HTTP 1.0 vs. HTTP 1.1 that made the difference.