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);
}
?>