SIM900 will not send an SMS - Info below

Hi All,

I am having problems with my SIM900 module connecting to the network. I am using my code (see below) to try and send a text to my phone when a switch is flicked. In the serial monitor I am getting this:





However sometimes I get the ‘SMS Test on/off’ show up as well, then my number shows up and then it will just say ERROR.
I have tried two different sim cards.
The netlight is also solid, both the status and netlight LEDS are solid for about 30 seconds, then they turn off. This seems to coincide with +CREG: 2 and +CREG: 1.
Can anybody please help me out? Heres my code.

#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8); // This is declaring what pins are being used for the transmit and receive from the arduino to the GSM
boolean state, lastState; // This is saying the value that it is looking for to trigger the call, so the last state of the pin

void setup()

  pinMode(9, OUTPUT); 
  pinMode(9, INPUT);

  pinMode(2, INPUT_PULLUP); // This is declaring what pin i am using for the input of the switch to the arduino
  state = digitalRead(2);
  lastState = state;
  GPRS.begin(9600); // This is starting the GSM board ready for use
  Serial.begin(9600); // This is starting the serial moniter which is a fucntion of arduino allowing you to read what it is doing 
                      //on your computer
void loop()
  while(GPRS.available()) {
  lastState = state;
  state = digitalRead(2); // This is telling the arduino to digital read the pin 2 to understand its state, whether it is 1 logic 1 or 0
  if ( state != lastState ) { //This is reading the state saying that if the state on pin 2 is different to what it was previously 
    //then to go to the command sendSMS which is further down the page
  delay(500); // Delay for 500ms

void sendSMS() { // This is the command that sends the text to the phone
  Serial.print("SMS Test "); 
  Serial.println(state ? "on" : "off"); //These 2 are just printing text on the serial monitor on the computer to tell you
                                        //that its working. it has nothing to do with the opertaion of the board
  GPRS.println("AT+CMGS=\"+xxxxxxxxx\""); //This is telling the arduino the telephone numebr to send the text to number blocked for privacy 
  delay(500); // This is a delay of 500ms to ensure that it is ready to send the text
  GPRS.print("SMS Test"); // This is the text that is sent to the phone. This is customizable to
                                                //have whatever you want on it. 
  GPRS.write( 0x1a ); // This is telling the arduino to delete the text that is in the text field once its been sent.