Hello, well I am new here, and have a question about why I can't connecto to 000webhost via ethernet shield this is my code.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
IPAddress server( 192,168,1,65 );
int s[20];
EthernetClient client;
void setup(){
Ethernet.begin(mac, gateway, subnet);
delay(1000);
Serial.begin(9600);
}
void loop(){
for(int a=0;a<20;a++){
s[a]=random(10, 15);
}
mysql_ins();
}
void mysql_ins(){
if (client.connect(server, 80)) {
client.print("GET /arduino/read.php?s1=");
client.print(s[0]);
for(int a=1;a<20;a++){
client.print("&s");
client.print(a+1);
client.print("=");
client.print(s[a]);
}
client.println(" HTTP/1.1");
client.println("Host: localhost");
client.println();
Serial.println("ARDUINO: HTTP message sent");
delay(3000);
if(client.available()){
Serial.println("ARDUINO: HTTP message received");
Serial.println("ARDUINO: printing received headers and script response...\n");
while(client.available()){
char c = client.read();
Serial.print(c);
}
}else{
Serial.println("ARDUINO: no response received / no response received in time");
}
client.stop();
}else{
Serial.println("connection failure");
}
}
When I do it in my local computer I can acces but, I cant in 000webhost I set the server ip as it show me in the Cpanel.