Arduino uno sending data to localhost

I am trying to configure my arduino uno to send some data over ethernet to the database hosted on my wamp server. However, when I run the code I currently have, nothing happens.

To configure my computer/wamp/router I used the following guide:

I am using the following php code to create the connection and execute the insert query. If I run this code using my URL bar (e.g “http://localhost/dbTest.php?value=300000” ) the code works fine and I can see the value appear in my database.

// Connection information
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "arduinotest";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// SQL query
$sql = "INSERT INTO testdata (myTime) VALUES ('".$_GET["value"]."')";

// Execute query

// Close connection

On the arduino end I am using the following code, the client connection always seems to pass.

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

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

IPAddress ip(192,168,0,10);
IPAddress server(192,168,0,4); 

EthernetClient client;

int data = 10;

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

void loop() {

  if (client.connect(server, 80)) {
    Serial.println("Connected successfully\n");

    // Print for debugging
    Serial.print("GET /dbTest.php?");
    Serial.println(" HTTP/1.1");
    Serial.print("Host: ");
    Serial.println("Connection: close");
    client.print("GET /dbTest.php?");
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println("Connection: close");

  else {
    Serial.println("Connection failed\n");

This is where I am currently at, I’ve run out of ideas as to what could be the cause. I’d be really grateful for any suggestions or help. Thanks.

Presuming the Arduino is connecting to the server, then change $servername to the IP of the server. ""

Thanks for the reply Tim, but when I change $servername to anything other than localhost is throws errors at me. Just to clarify, aren't localhost and the sever address equivalent? What is the reason behind changing it to the IP address form?

Have you tried the same from a PC on the same localnet? Maybe a firewall problem?

BTW, localhost is only valid on the server.

BTW, localhost is only valid on the server.

localhost is a name that means that the server is the same machine that the client is running on. The Arduino is the client. It is NOT the server, so using localhost is wrong, no matter how badly you want it to be right.

What Paul said - "localhost" is a special name - see localhost - Wikipedia