help me i wanna control led pass internet

i use internet client to control led
i have button on and off on my webpage when i pass on data in sql will be change to on then i pass off data in sql change to off and arduino check data in php page that show data in mysql so my code do it one time when i loop my led blink high and low. help me pls . sorry for my bad english

/*
  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>
String readString; 
int led = 7;
int outPin = 8;
// 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[] = "myweb.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,1,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:
 pinMode(outPin, OUTPUT);
  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 /data.php HTTP/1.1");
    client.println("Host: myweb.com");
    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();
    if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        }
       if (c == '\n') {
         Serial.println(readString); //print to serial monitor for debuging 
       if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(led, HIGH);    // set pin 5 high
            digitalWrite(outPin, HIGH);
            Serial.println("Led On");
          }
       if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(led, LOW);
            digitalWrite(outPin, LOW);
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";
  }
  }
  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

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

help me pls

OK:

char server[] = "myweb.com";    // name address for Google (using DNS)

I'm pretty sure that that is not google's URL.

If you really want help, you need to explain what the code you posted does, and how that differs from what you want it to do.

PaulS:

help me pls

OK:

char server[] = "myweb.com";    // name address for Google (using DNS)

I'm pretty sure that that is not google's URL.

If you really want help, you need to explain what the code you posted does, and how that differs from what you want it to do.

char server[] = "myweb.com";    // name address for Google (using DNS)

it is myweb not google.com

my code check data on page if my data is on led will turn on if my data is off my led will turn off
it work but i wanna loop this code always check my page if on led is on if off led is off
i try to loop this but it not work i change data on to off but my led dont turn off

or you have any idea to control led pass internet by web client
i use mega 2560r3 and ethernetshield and wifi bridge

thank for help

it is myweb not google.com

Then why haven't you deleted the incorrect comment?

but i wanna loop this code

It might be a language thing, but "loop this code" generally means that the poster doesn't have a clue what he or she wants to do.

always check my page

Impossible. No client can see what another client has rendered. If one client has rendered something based on the contents of a SQL database, another client can access that same database.

In your case, you only make one GET request, when the Arduino is reset. You need to make periodic requests, in loop().

but i wanna loop this code

It might be a language thing, but “loop this code” generally means that the poster doesn’t have a clue what he or she wants to do.
i wanna use this code for check
if data == 1 led turn on
else if data ==2 led turn off

check on page(that show data in database) or my database

always check my page

Impossible. No client can see what another client has rendered. If one client has rendered something based on the contents of a SQL database, another client can access that same database.

In your case, you only make one GET request, when the Arduino is reset. You need to make periodic requests, in loop().
[/quote]
can it check in sql database

thanks

can it check in sql database

No and yes. No, the Arduino can not read what is in the sql database on some other computer, but, yes, it can execute a script on that server (as your code does now) that reads the sql database and returns the required information from the database.

You sketch just needs to do that in loop(), not in setup().

do you have any tutorial or example of this ?

thanks

narunsa:
do you have any tutorial or example of this ?

At the top of the page, in the big green navigation bar, you will find Learning. In the dropdown, you will find Examples. If you click on that, you will get to a page that explains the examples that are supplied with the IDE. Load the example code from the IDE, compile, run, and read through the explanations.

Or you could buy one of the books available

A simple setup to turn an arduino pin (LED) on/off via an arduino generated web page.

//zoomkat 10-6-13
//simple button GET with iframe code
//open serial monitor to see what the arduino receives
//use the ' instead of " in html ilnes 
//address will look like http://192.168.1.102:84/ when submited
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //ethernet shield mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino IP in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 

//////////////////////

void setup(){

  pinMode(4, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("servertest1"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

          //now output HTML data header
             if(readString.indexOf('?') >=0) { //don't send new page
               client.println("HTTP/1.1 204 Zoomkat");
               client.println();
               client.println();  
             }
             else {
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Zoomkat's simple Arduino button</H1>");
          
          client.println("<a href='/?on1' target='inlineframe'>ON</a>"); 
          client.println("<a href='/?off' target='inlineframe'>OFF</a>"); 

          client.println("<IFRAME name=inlineframe style='display:none'>");          
          client.println("</IFRAME>");

          client.println("</BODY>");
          client.println("</HTML>");
             }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on1") >0)//checks for on
          {
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

sorry
what can i apply your web code???
i don't know how to do with it...
thank u