Call local PHP page with URL Variable that query a MySQL Database.

Dear All,

I've been scratching my head on this for 2 day now before I try to post on this forum to pick on the collective mind (BORG 101). :smiley:

The code below is from the Arduino IDE Example for Ethernet for WebClientRepeating. I am trying to test the code to load a php page that queries a mySQL database. It doesn't seems to work. Somehow when I tried webserver call using telnet :

GET /j.php?id=123&gateID=Gate1 HTTP/1.1
Host: 192.168.0.99
User-Agent: arduino-ethernet
Connection: close

it's giving me this respond :

501 Not Implemented

I tried the whole url using chrome : /j.php?id=123&gateId=Gate1
it worked

// this method makes a HTTP connection to the server:
void httpRequest(String memberId, String gateId){
// close any connection before send a new request.
  // This will free the socket on the WiFi shield

  client.stop();

  // if there's a successful connection:
  if (client.connect(server, 80)) {
    
    Serial.println("connecting...");
    // send the HTTP PUT request:
    
    // Formats the Url call to factor in MemberID and GateID
    String pageCall;
    
    pageCall = "GET /j.php?id=" + memberId + "&gateId=" + gateId + " HTTP/1.1";


    client.println(pageCall);
//    client.println("GET /j.php?id=10 HTTP/1.1");
    client.println("Host: 192.168.0.99");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    
    Serial.print("PageCall :");
    Serial.println(pageCall);
    Serial.println("Host: 192.168.0.99");
    Serial.println("User-Agent: arduino-ethernet");
    Serial.println("Connection: close");
 
    
  }
  else {  
    // if you couldn't make a connection:
    Serial.println("connection failed");
    client.stop();
  }
}

Your comments stating the obvious look pretty stupid when the code then does something else.

Most of the time, there is no need to specify the Host: line. It is needed only if the server is hosting multiple domains. It is unlikely that your server is hosting multiple domains.

It is almost never necessary to specify the User-Agent.

The default action is to close the connection after the transaction.

It is ALWAYS necessary to post all of your code and any serial output that you get.

http://www.checkupdown.com/status/E501.html

After much testing I've found the error. Need to put a client.println(); (carriage return and new line) code at the end to make sure that the web server respond I've added 3 of those.. Now it's working.