尝试将以太网屏蔽连接到本地Apache服务器

So for the most part I have had really great luck with the ethernet shield that I recently purchased. I am now trying to upload analog data from the arduino to a local mysql db. My write_data.php file seems to be working perfectly and I can upload data to the data base whenever I call the write_data.php file in the url. Although the arduino always fails to connect. I am using a netgear router and I checked the allowed devices list on the netgear genie network admin and the arduino was listed, which makes sense because it has worked for all of my other projects. Would really apprieciate some advice and ideas here. Also, not sure if this would make a difference but I am using mamp as my local server enviroment. The censored files are below :

write_data.php:

<?php

    // Prepare variables for database connection

    $dbusername = "test";  // enter database username, I used "arduino"    in step 2.2
    $dbpassword = "test";  // enter database password, I used   "arduinotest" in step 2.2
    $server = "50.135.xxx.xxx"; // IMPORTANT: if you are using XAMPP enter "localhost", but if you have an online website enter its address, ie."www.yourwebsite.com"

    // Connect to your database

    $dbconnect = mysql_pconnect($server, $dbusername, $dbpassword);
    $dbselect = mysql_select_db("Test",$dbconnect);

    // Prepare the SQL statement

    $sql = "INSERT INTO Test.Sensor (value) VALUES   ('".$_GET["value"]."')";    

    // Execute SQL statement

    mysql_query($sql);

?>

arduino sketch:

#include SPI.h

#include Ethernet.h

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

// Enter the IP address for Arduino, as mentioned we will use   192.168.0.16
// Be careful to use , insetead of . when you enter the address here

IPAddress ip(192,xxx,xx,xx);

int photocellPin = 2;  // Analog input pin on Arduino we connected the    SIG pin from sensor
int photocellReading;  // Here we will place our reading

char server[] = "50.135.xxx.xxx"; // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie. "www.yourwebpage.com")

// Initialize the Ethernet server library
EthernetClient client;

void setup() {

  // Serial.begin starts the serial connection between computer and Arduino
  Serial.begin(9600);

  // start the Ethernet connection
  Ethernet.begin(mac ,ip);

}



void loop() {

  photocellReading = analogRead(photocellPin); // Fill the    sensorReading with the information from sensor

  // Connect to the server (your computer or web page)  
  if (client.connect(server,8888)) {
    client.print("GET /write_data.php?"); // This
    client.print("value="); // This
    client.print(photocellReading); // And this is what we did in the   testing section above. We are making a GET request just like we would from   our browser but now with live data from the sensor
    client.println(" HTTP/1.1"); // Part of the GET request
    client.println("Host: 50.135.xxx.xxx"); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie.Host: "www.yourwebpage.com")
    client.println("Connection: close"); // Part of the GET request telling the server that we are over transmitting the message
    client.println(); // Empty line
    client.println(); // Empty line
    client.stop();    // Closing connection to server

  }

  else {
    // If Arduino can't connect to the server (your computer or web page)
    Serial.println("--> connection failed
");
  }

  // Give the server some time to recieve the data and store it. I used 10 seconds here. Be advised when delaying. If u use a short delay, the server might not capture data because of Arduino transmitting new data too soon.
  delay(10000);
}

Had same problem some weeks ago. You "recently" purchased the Ethernet Shield so it may be an Ethernet2 shield and not an Ethernet shield. You should include "Ethernet2.h" instead of "Ethernet.h" which is only in the IDE from Arduino.org and not in Arduino.cc.