Problem sending RFID-read data over ethernet

Hi there. I’m trying to build a prototype of a system that allows users to move library books around a building, and register where they are by swiping them on RFID readers. I have the LAMP stack down, and separately have an adapted version of the Parallax reader code ((http://www.arduino.cc/playground/Learning/PRFID) adapted so that it only acts when the Parallax reads a novel tag, getting around its always-reading function) that works fine, and can also get the ethernet shield test code (http://arduino.cc/en/Reference/ClientConnect) working fine (albeit after updating it with Google’s current IP, 209.85.135.105.

My problem is that, even after borrowing from some code that seems to be able to send read data to the internet (jfkrouter’s code from http://www.jfkreuter.com/?p=80#more-80, found through the discussion http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276885527/6), I cannot seem to get the ethernet and RFID code to work together.

I’m in the processing of purchasing a dedicated IP address, as I know I’ll need that eventually, so right now I just want to execute the client.print(“GET /search?q=arduino HTTP/1.0”); line when the parallax reads a novel tag. Instead, the serial outputs “Cannot connect to server”, and only once (when it should say that every time it reads a novel tag and goes through the IF/ELSE of trying to send that tag’s data to the internet.

Code is below:

// adapted from http://www.jfkreuter.com/?p=80#more-80 - 2010/07/30

#include <Ethernet.h>           //library for ethernet functions
#include <Client.h>             //library for client functions

// RFID settings
int val = 0;
char lastValue[10];
char tagValue[10]; 
int bytesread = 0; 
// Ethernet settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xBE}; // mac-adress of arduino
byte ip[] = { 192, 168, 0, 2 };                     // IP-adress of arduino
byte server[] = { 209, 85, 135, 105 };              // Google

Client client(server, 80);         

void setup()                                  
{
  Serial.begin(2400);                               // start the serial port
  delay(1000);
  Serial.println("connecting...");

  Ethernet.begin(mac, ip);                  // start up ethernet
  pinMode(2,OUTPUT);                        // pin 2 is the output to the reader
  digitalWrite(2,LOW);                      // ... and now the reader has been actived

  if (client.connect()) 
  {
    Serial.println("connected");
    //client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } 
  else 
  {
    Serial.println("connection failed");
  }
}
//----------------------------------------------------------------------------------------------------------
void loop(void)                     // loop function (runs over and over again)
{
  if(Serial.available() > 0)                // if data available from reader 
  {
    if((val = Serial.read()) == 10)         // check for header 
    {
      bytesread = 0; 
      while(bytesread<10)                   // read 10 digit code 
      {
        if( Serial.available() > 0) 
        {
          val = Serial.read(); 
          if((val == 10)||(val == 13))       // if header or stop bytes before the 10 digit reading 
          {
            break;                           // stop reading 
          }  
          tagValue[bytesread] = val;         // add the digit           
          bytesread++;                       // ready to read next digit  
        } 
      } 
      if(bytesread == 10)                    // if 10 digit read is complete 
      {
        if ((tagValue[0] == lastValue[0]) && 
          (tagValue[1] == lastValue[1]) && 
          (tagValue[2] == lastValue[2]) && 
          (tagValue[3] == lastValue[3]) && 
          (tagValue[4] == lastValue[4]) && 
          (tagValue[5] == lastValue[5]) && 
          (tagValue[6] == lastValue[6]) && 
          (tagValue[7] == lastValue[7]) && 
          (tagValue[8] == lastValue[8]) && 
          (tagValue[9] == lastValue[9]))
        {
          /* do... nothing                       this tests for a non-novel tag */
        }
        else
        {
          if (client.connect())
          {
            client.print("GET /search?q=arduino HTTP/1.0");
            Serial.print("GET /search?q=arduino HTTP/1.0");
            /*
            client.print("GET /changeTagLocation.php?targetLocation=2&targetTag=");
            Serial.print("GET /changeTagLocation.php?targetLocation=2&targetTag=");
            client.print(tagValue);
            Serial.print(tagValue);
            client.println(" HTTP/1.0");
            Serial.println(" HTTP/1.0");
            client.println("Host: www.thisishere.net");
            Serial.println("Host: www.thisishere.net");
            client.println("User-Agent: Arduino");
            Serial.println("User-Agent: Arduino");
            client.println("Accept: text/html");
            Serial.println("Accept: text/html");
            client.println("Connection: close");
            Serial.println("Connection: close");
            */
            client.println();
            Serial.println();
          }
          else
          {
            Serial.println("Cannot connect to Server");         //  else block if the server connection fails (debugging)
          }
          Serial.println();
          client.stop();                                              //  stop the connection and set
          delay(598400);
        }
      }
    }
  }
}

You really should either post a reply to a thread or create a new post, but not both.