Hmm, yeah, you can't just make up PHP syntax and hope it will work.
Your form elements / values aren't magically included during IPN processing. Typically we would read the form data in for you in something like this, but with PayPal IPN processing, you want to keep processing time to the minimum, and hand a response back to PayPal as quick as you can.
So you have two choices. One is to read the form data in from the database during your IPN processing, but as explained ^^ there, that's a slow database operation you should avoid if possible.
The other option is to include any data you are going to want to use during your IPN handling, in the "IPN Custom Value" field in the main plugin settings. Which is what it's for. Anything you put in there gets sent to PayPal with the payment request, and PayPal then just send it back in the IPN response. So you can associate any of your specific app data with a payment request, for use in the IPN response(s).
So ... in your "IPN Custom Value", put the {tablename___item_id_raw} placeholder, and select a filed to use as the IPN Custom Element. If necessary, create a simple field element for it. Let's assume it's called yourtable___ipn_custom.
Then in your script ...
PHP:
function payment_status_Completed($listModel, $request, &$set_list, &$err_msg) {
$item_id = $set_list['ipn_custom'];
$pp_db = JFactory::getDbo();
$pp_query = $pp_db->getQuery(true);
$pp_query->update('tablename_items')->set("status = '3'")->where('id = ' . $pp_db->quote($item_id));
$pp_db->setQuery($pp_query);
$pp_db->execute();
return 'ok';
}
-- hugh