I am new to php. I recently moved a working site from one server to another. Everything is working except this one page. It fails to send out one email and is displaying this error at the bottom of the page:

Parse error: syntax error, unexpected '}' on line 201

This is the code:
}

// if the IPN POST was 'INVALID'...do this

else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation

mail($notify_email, "INVALID IPN", "$res\n $req\n $headers");
}

fclose ($fp);
}
?>

Can anyone help?

    Yes, I believe it does. In reviewing the code for the full document, I have 11 sets of brackets. If I remove the bracket on line 201, I receive the following error:

    Warning: fclose(): 3 is not a valid stream resource on line 200.

    Line 200 is:

    fclose ($fp);

    So I put the bracket back in, which takes me back to the original error.

      I am posting from the first if statement on. Hopefully that is what you wanted to see.

      if (strcmp ($res, "VERIFIED") == 0) {
      
      $notify_email =  "tulip88@website.com";         //email address to which debug emails are sent to
      
      $DB_Server = "localhost"; //your MySQL Server
      $DB_Username = "xxxxxxxxxx"; //your MySQL User Name
      $DB_Password = "xxxxxxxxxx"; //your MySQL Password
      $DB_DBName = "xxxxxxxxxxxx"; //your MySQL Database Name
      
      
      
      //create MySQL connection
      $Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
      or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
      
      
      //select database
      $Db = @mysql_select_db($DB_DBName, $Connect)
      or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
      
      
      $fecha = date("m")."/".date("d")."/".date("Y");
      $fecha = date("Y").date("m").date("d");
      
      //check if transaction ID has been processed before
      $checkquery = "select txnid from paypal_payment_info where txnid='".$txn_id."'";
      $sihay = mysql_query($checkquery) or die("Duplicate txn id check query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
      $nm = mysql_num_rows($sihay);
      if ($nm == 0){
      
      //execute query
      
      
      
      if ($txn_type == "cart"){
      $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
      
       $result = mysql_query($strQuery) or die("Cart - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
       for ($i = 1; $i <= $num_cart_items; $i++) {
           $itemname = "item_name".$i;
           $itemnumber = "item_number".$i;
           $on0 = "option_name1_".$i;
           $os0 = "option_selection1_".$i;
           $on1 = "option_name2_".$i;
           $os1 = "option_selection2_".$i;
           $quantity = "quantity".$i;
      
           $struery = "insert into paypal_cart_info(txnid,itemnumber,itemname,os0,on0,os1,on1,quantity,invoice,custom) values ('".$txn_id."','".$_POST[$itemnumber]."','".$_POST[$itemname]."','".$_POST[$on0]."','".$_POST[$os0]."','".$_POST[$on1]."','".$_POST[$os1]."','".$_POST[$quantity]."','".$invoice."','".$custom."')";
           $result = mysql_query($struery) or die("Cart - paypal_cart_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
      
       }
      }
      
      
      
      else{
       $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
       $result = mysql_query("insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')") or die("Default - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
      }
      
      
      
      
      // send an email in any case
      	 // mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
      $msg .= Website Music - Thank You for your Purchase! \n\n";
      $msg .= "Payment Details \n\n";
      $msg .= "Name: ".$first_name." ".$last_name." \n";
      $msg .= "Your Email: ".$payer_email." \n";
      $msg .= "Transaction ID: ".$txn_id." \n\n";
      $msg .= $msg1;
      $msg .= " \n\n";
      $msg .= "The email address we used to send this Transaction Notice is only used for product delivery purposes, so please do not respond or attempt to correspond with us by replying to this email. No one will ever see it. \n\n";
      $msg .= "If you have any questions regarding your order, please contact us at [email]Orders@website.com[/email] or you may want to review our Contact page here [url]http://www.website.com/index-new.php?p=contact[/url] \n\n";
      $msg .= "If you have an account at [url]www.PayPal.com[/url], you can log in and review the details of this transaction. \n\n";
      if ($send_link == "yes" ) {
      $msg .= "To access your Download(s) use the following link: \n";
      $msg .= "http://www.website.com/DL/GetFiles.php?ta=".$txn_id."&ad=".$payer_email."  \n\n";
      }
      $msg .= "Thank you for allowing us to serve you, it is our great pleasure. \n\n";
      $msg .= "xxxxx Founder \n";
      $msg .= Website Music \n\n";
      mail($payer_email, Website Music - Information", $msg, $mailheaders);
      $msg = "";
      
      
      // Mail to Joe
      $msg .= "Hello Joe You have a new sale! \n\n";
      $msg .= "Payment Details \n\n";
      $msg .= "Name: ".$first_name." ".$last_name." \n";
      $msg .= "Your Email: ".$payer_email." \n";
      $msg .= "Transaction ID: ".$txn_id." \n\n";
      $msg .= "~~~~~~~~~~~~~~      Address      ~~~~~~~~~~~~~~~~ \n";
      $msg .= $address_street." \n";
      $msg .= $address_city.", ";
      $msg .= $address_state." ";
      $msg .= $address_zip." \n";
      $msg .= "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n";
      $msg .= " \n\n";
      $msg .= $msg1;
      $msg .= " \n\n";
      if ($send_link == "yes" ) {
      $msg .= "Here is their Download page: \n";
      $msg .= "http://www.website.com/DL/GetFiles.php?ta=".$txn_id."&ad=".$payer_email."  \n\n";
      }
      $msg .= "Have a nice day Joe. \n\n";
      $msg .= "Ken \n";
      $msg .= " \n\n";
      mail($notify_email, "VERIFIED IPN", $msg, $mailheaders);
      }
      else {
      // send an email mail($to, $subject, $msg, $mailheaders);
      $msg = "$res\n $req \n $strQuery\n $struery\n  $strQuery2";
      mail($notify_email, "VERIFIED DUPLICATED TRANSACTION", $msg, $headers);
      }
      
      //subscription handling branch
      if ( $txn_type == "subscr_signup"  ||  $txn_type == "subscr_payment"  ) {
      
        // insert subscriber payment info into paypal_payment_info table
        $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
        $result = mysql_query($strQuery) or die("Subscription - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
      
      
           // insert subscriber info into paypal_subscription_info table
          $strQuery2 = "insert into paypal_subscription_info(subscr_id , sub_event, subscr_date ,subscr_effective,period1,period2, period3, amount1 ,amount2 ,amount3,  mc_amount1,  mc_amount2,  mc_amount3, recurring, reattempt,retry_at, recur_times, username ,password, payment_txn_id, subscriber_emailaddress, datecreation) values ('".$subscr_id."', '".$txn_type."','".$subscr_date."','".$subscr_effective."','".$period1."','".$period2."','".$period3."','".$amount1."','".$amount2."','".$amount3."','".$mc_amount1."','".$$mc_amount2."','".$$mc_amount3."','".$recurring."','".$reattempt."','".$retry_at."','".$recur_times."','".$username."','".$password."', '".$txn_id."','".$payer_email."','".$fecha."')";
          $result = mysql_query($strQuery2) or die("Subscription - paypal_subscription_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
      
      
               mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
      
      }
      }
      
      // if the IPN POST was 'INVALID'...do this
      
      
      else if (strcmp ($res, "INVALID") == 0) {
      // log for manual investigation
      
      mail($notify_email, "INVALID IPN", "$res\n $req\n $headers");
      }
      
      fclose ($fp);
      }
      ?>

        When posting PHP code, please use the board's [noparse]

        [/noparse] bbcode tags as they make your code much easier to read.

        For example, once I added those tags to your post, the missing opening quote on the follow line became quite obvious (look at the color coding):

            $msg .= Website Music - Thank You for your Purchase! nn"; 

          I'm very grateful for your response. However, I am new to php code so these things are not obvious to me. I am trying to figure out what to change on this page to make it work, but I am still confused.

                $msg .= Website Music - Thank You for your Purchase! nn"; 
            

            should be

                $msg .= "Website Music - Thank You for your Purchase! \n\n"; 
            

            strings

              I can see what you are talking about. But when I review the code (all I did was a copy & paste) the /n/n is there. However, it is not showing up in what is posted to this message board. I'm going to send just a portion again, to see how it shows up.

              // send an email in any case
              	 // mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
              $msg .= Website Music - Thank You for your Purchase! \n\n";
              $msg .= "Payment Details \n\n";
              $msg .= "Name: ".$first_name." ".$last_name." \n";
              $msg .= "Your Email: ".$payer_email." \n";
              $msg .= "Transaction ID: ".$txn_id." \n\n";
              $msg .= $msg1;
              $msg .= " \n\n";
              $msg .= "The email address we used to send this Transaction Notice is only used for product delivery purposes, so please do not respond or attempt to correspond with us by replying to this email. No one will ever see it. \n\n";
              $msg .= "If you have any questions regarding your order, please contact us at [email]Orders@website.com[/email] or you may want to review our Contact page here [url]http://www.website.com/index-new.php?p=contact[/url] \n\n";
              $msg .= "If you have an account at [url]www.PayPal.com[/url], you can log in and review the details of this transaction. \n\n";
              if ($send_link == "yes" ) {
              $msg .= "To access your Download(s) use the following link: \n";
              $msg .= "http://www.website.com/DL/GetFiles.php?ta=".$txn_id."&ad=".$payer_email."  \n\n";
              }
              $msg .= "Thank you for allowing us to serve you, it is our great pleasure. \n\n";
              $msg .= "xxxxx Founder \n";
              $msg .= Website Music \n\n";
              mail($payer_email, Website Music - Information", $msg, $mailheaders);
              $msg = "";

                \n is a line break, its for the email

                  But the code seems to be in place:

                  $msg .= Website Music - Thank You for your Purchase! \n\n";

                  I still don't understand what is missing.

                  Again, I am new to php so please forgive my lack of knowledge.

                    I finally see what you were telling me to correct. That was actually my error in posting the code. Here is a corrected post. I still have the original error -- on line 201. I have added the quote tags to this post. Hopefully I did that right.

                    if (strcmp ($res, "VERIFIED") == 0) {
                    
                    $notify_email =  "tulip88@website.com";         //email address to which debug emails are sent to
                    
                    $DB_Server = "localhost"; //your MySQL Server
                    $DB_Username = "xxxxxxxxxx"; //your MySQL User Name
                    $DB_Password = "xxxxxxxxxx"; //your MySQL Password
                    $DB_DBName = "xxxxxxxxxxxx"; //your MySQL Database Name
                    
                    
                    
                    //create MySQL connection
                    $Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
                    or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
                    
                    
                    //select database
                    $Db = @mysql_select_db($DB_DBName, $Connect)
                    or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
                    
                    
                    $fecha = date("m")."/".date("d")."/".date("Y");
                    $fecha = date("Y").date("m").date("d");
                    
                    //check if transaction ID has been processed before
                    $checkquery = "select txnid from paypal_payment_info where txnid='".$txn_id."'";
                    $sihay = mysql_query($checkquery) or die("Duplicate txn id check query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
                    $nm = mysql_num_rows($sihay);
                    if ($nm == 0){
                    
                    //execute query
                    
                    
                    
                    if ($txn_type == "cart"){
                    $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
                    
                     $result = mysql_query($strQuery) or die("Cart - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
                     for ($i = 1; $i <= $num_cart_items; $i++) {
                         $itemname = "item_name".$i;
                         $itemnumber = "item_number".$i;
                         $on0 = "option_name1_".$i;
                         $os0 = "option_selection1_".$i;
                         $on1 = "option_name2_".$i;
                         $os1 = "option_selection2_".$i;
                         $quantity = "quantity".$i;
                    
                         $struery = "insert into paypal_cart_info(txnid,itemnumber,itemname,os0,on0,os1,on1,quantity,invoice,custom) values ('".$txn_id."','".$_POST[$itemnumber]."','".$_POST[$itemname]."','".$_POST[$on0]."','".$_POST[$os0]."','".$_POST[$on1]."','".$_POST[$os1]."','".$_POST[$quantity]."','".$invoice."','".$custom."')";
                         $result = mysql_query($struery) or die("Cart - paypal_cart_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
                    
                     }
                    }
                    
                    
                    
                    else{
                     $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
                     $result = mysql_query("insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')") or die("Default - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
                    }
                    
                    
                    
                    
                    // send an email in any case
                    	 // mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
                    $msg .= "Website Music - Thank You for your Purchase! \n\n";
                    $msg .= "Payment Details \n\n";
                    $msg .= "Name: ".$first_name." ".$last_name." \n";
                    $msg .= "Your Email: ".$payer_email." \n";
                    $msg .= "Transaction ID: ".$txn_id." \n\n";
                    $msg .= $msg1;
                    $msg .= " \n\n";
                    $msg .= "The email address we used to send this Transaction Notice is only used for product delivery purposes, so please do not respond or attempt to correspond with us by replying to this email. No one will ever see it. \n\n";
                    $msg .= "If you have any questions regarding your order, please contact us at Orders@website.com or you may want to review our Contact page here http://www.website.com/index-new.php?p=contact \n\n";
                    $msg .= "If you have an account at www.PayPal.com, you can log in and review the details of this transaction. \n\n";
                    if ($send_link == "yes" ) {
                    $msg .= "To access your Download(s) use the following link: \n";
                    $msg .= "http://www.website.com/DL/GetFiles.php?ta=".$txn_id."&ad=".$payer_email."  \n\n";
                    }
                    $msg .= "Thank you for allowing us to serve you, it is our great pleasure. \n\n";
                    $msg .= "xxxxx Founder \n";
                    $msg .= "Website Music \n\n";
                    mail($payer_email, "Website Music - Information", $msg, $mailheaders);
                    $msg = "";
                    
                    
                    // Mail to Joe
                    $msg .= "Hello Joe You have a new sale! \n\n";
                    $msg .= "Payment Details \n\n";
                    $msg .= "Name: ".$first_name." ".$last_name." \n";
                    $msg .= "Your Email: ".$payer_email." \n";
                    $msg .= "Transaction ID: ".$txn_id." \n\n";
                    $msg .= "~~~~~~~~~~~~~~      Address      ~~~~~~~~~~~~~~~~ \n";
                    $msg .= $address_street." \n";
                    $msg .= $address_city.", ";
                    $msg .= $address_state." ";
                    $msg .= $address_zip." \n";
                    $msg .= "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n";
                    $msg .= " \n\n";
                    $msg .= $msg1;
                    $msg .= " \n\n";
                    if ($send_link == "yes" ) {
                    $msg .= "Here is their Download page: \n";
                    $msg .= "http://www.website.com/DL/GetFiles.php?ta=".$txn_id."&ad=".$payer_email."  \n\n";
                    }
                    $msg .= "Have a nice day Joe. \n\n";
                    $msg .= "Ken \n";
                    $msg .= " \n\n";
                    mail($notify_email, "VERIFIED IPN", $msg, $mailheaders);
                    }
                    else {
                    // send an email mail($to, $subject, $msg, $mailheaders);
                    $msg = "$res\n $req \n $strQuery\n $struery\n  $strQuery2";
                    mail($notify_email, "VERIFIED DUPLICATED TRANSACTION", $msg, $headers);
                    }
                    
                    //subscription handling branch
                    if ( $txn_type == "subscr_signup"  ||  $txn_type == "subscr_payment"  ) {
                    
                      // insert subscriber payment info into paypal_payment_info table
                      $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
                      $result = mysql_query($strQuery) or die("Subscription - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
                    
                    
                         // insert subscriber info into paypal_subscription_info table
                        $strQuery2 = "insert into paypal_subscription_info(subscr_id , sub_event, subscr_date ,subscr_effective,period1,period2, period3, amount1 ,amount2 ,amount3,  mc_amount1,  mc_amount2,  mc_amount3, recurring, reattempt,retry_at, recur_times, username ,password, payment_txn_id, subscriber_emailaddress, datecreation) values ('".$subscr_id."', '".$txn_type."','".$subscr_date."','".$subscr_effective."','".$period1."','".$period2."','".$period3."','".$amount1."','".$amount2."','".$amount3."','".$mc_amount1."','".$$mc_amount2."','".$$mc_amount3."','".$recurring."','".$reattempt."','".$retry_at."','".$recur_times."','".$username."','".$password."', '".$txn_id."','".$payer_email."','".$fecha."')";
                        $result = mysql_query($strQuery2) or die("Subscription - paypal_subscription_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
                    
                    
                             mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
                    
                    }
                    }
                    
                    // if the IPN POST was 'INVALID'...do this
                    
                    
                    else if (strcmp ($res, "INVALID") == 0) {
                    // log for manual investigation
                    
                    mail($notify_email, "INVALID IPN", "$res\n $req\n $headers");
                    }
                    
                    fclose ($fp);
                    }
                    ?>
                    

                      Hi, the line ...

                      fclose ($fp);

                      ... assumes that $fp is a 'file pointer', meaning that somewhere earlier in the code there should be a line similar to...

                      $fp = fopen(...);

                      ... which opens a file.

                      Can't see 'fopen' anywhere in the code you posted - have you posted the whole code?

                      P.

                        I have a few lines of code at the top which describe the variables:

                        // assign posted variables to local variables
                        $item_name = $_POST['item_name'];
                        $business = $_POST['business'];
                        $item_number = $_POST['item_number'];
                        $payment_status = $_POST['payment_status'];

                        I just searched the document and I don't see an fopen either. Should I remove it?

                          So, to be sure, the entirety of the code is what you posted before plus, at the top, just these assignments. No includes, requires or anything else.

                          If that's the case then yes, comment out the last two lines ...

                          mail($notify_email, "INVALID IPN", "$res\n $req\n $headers");
                          }
                          
                          //fclose ($fp);
                          //}

                          ... and see if that works.

                          P

                            Yes, that worked! The page comes up clean now. However, I still have a problem. The page should send out 2 emails.

                            The first email is showing in the code here:

                             
                                // send an email in any case

                            The second email is showing in the code here:

                            	// Mail to Joe

                            I was receiving the "mail to joe" with the original error. With the error corrected, I am still only receiving one email. The funny thing is, this worked before. I simply moved the site from one server to another. Please let me know if I should repost the code. Thank you!

                              I'm afraid we still haven't established whether this is the 'whole' code.

                              I just noticed in your earlier post (at the top) you have ...

                              if (strcmp ($res, "VERIFIED") == 0) {

                              Here $res must be the result of something (probably a return from a database) ... there must be more to it than what you're showing us.

                              Check again - post the whole code up otherwise we'll get in a mess (remember to XXX out any personal details as you did before).

                              P.

                                My full page is too long for the board. I will post the top section here. This is everything that was missing from the original post.

                                // assign posted variables to local variables
                                $item_name = $_POST['item_name'];
                                $business = $_POST['business'];
                                $item_number = $_POST['item_number'];
                                $payment_status = $_POST['payment_status'];
                                $mc_gross = $_POST['mc_gross'];
                                $payment_currency = $_POST['mc_currency'];
                                $txn_id = $_POST['txn_id'];
                                $receiver_email = $_POST['receiver_email'];
                                $receiver_id = $_POST['receiver_id'];
                                $quantity = $_POST['quantity'];
                                $num_cart_items = $_POST['num_cart_items'];
                                $payment_date = $_POST['payment_date'];
                                $first_name = $_POST['first_name'];
                                $last_name = $_POST['last_name'];
                                $payment_type = $_POST['payment_type'];
                                $payment_status = $_POST['payment_status'];
                                $payment_gross = $_POST['payment_gross'];
                                $payment_fee = $_POST['payment_fee'];
                                $settle_amount = $_POST['settle_amount'];
                                $memo = $_POST['memo'];
                                $payer_email = $_POST['payer_email'];
                                $txn_type = $_POST['txn_type'];
                                $payer_status = $_POST['payer_status'];
                                $address_street = $_POST['address_street'];
                                $address_city = $_POST['address_city'];
                                $address_state = $_POST['address_state'];
                                $address_zip = $_POST['address_zip'];
                                $address_country = $_POST['address_country'];
                                $address_status = $_POST['address_status'];
                                $item_number = $_POST['item_number'];
                                $tax = $_POST['tax'];
                                $option_name1 = $_POST['option_name1'];
                                $option_selection1 = $_POST['option_selection1'];
                                $option_name2 = $_POST['option_name2'];
                                $option_selection2 = $_POST['option_selection2'];
                                $for_auction = $_POST['for_auction'];
                                $invoice = $_POST['invoice'];
                                $custom = $_POST['custom'];
                                $notify_version = $_POST['notify_version'];
                                $verify_sign = $_POST['verify_sign'];
                                $payer_business_name = $_POST['payer_business_name'];
                                $payer_id =$_POST['payer_id'];
                                $mc_currency = $_POST['mc_currency'];
                                $mc_fee = $_POST['mc_fee'];
                                $exchange_rate = $_POST['exchange_rate'];
                                $settle_currency  = $_POST['settle_currency'];
                                $parent_txn_id  = $_POST['parent_txn_id'];
                                // Email headers
                                $mailheaders  = "From: Website - product-delivery@Website.com \n";
                                $mailheaders .= "Reply-To: product-delivery@Website.com \n";
                                   

                                The code continues from here with my original post. Let me know if I should repost this in a second message.

                                  I think you may have made an error somehow when you first moved/copied this file to the new location.

                                  Nowhere in the new code does $res get a mention - now we have two variables that, in the code you've shown so far, are expected to have values of some sort but don't.

                                  By the way, what is this file called (something.php) ... and how does it sit within the website?

                                  P.