I am trying to verify the mc_gross variable for a Pay Pal subscription IPN.
The following code keeps giving me "Resource id #12" value for the amount_data. The number I'm trying to verify is 0.05 that was put in the table when the user went to pay. The variable $id tests correctly and the number (0.05) is there in the payment_amount column - so I don't know why it can't do this query. I am new to MYSQL so I apologize for any obvious mistakes.
$payment_amount = mysql_real_escape_string($_POST['mc_gross']);
$amount_data = mysql_query ("SELECT * FROM subscriber WHERE payment_amount = '$payment_amount' AND id = '$id' ");
if ($amount_data != $_POST['mc_gross']) {
$errmsg .= "'mc_gross' does not match: ";
$errmsg .= $_POST['mc_gross']."\n";
file_put_contents(dirname(__FILE__).'/logs/ipn.log',"\n###AMOUNT Don't MATCH Amount in Database='$payment_amount' Amount in requested='$amount_data'for id '$id'###\n",FILE_APPEND);
}
Use mysql_fetch_row()
to get the $amount_data.Mysql_query() returns only the resouce id
$amount_data = mysql_query ("SELECT * FROM subscriber WHERE payment_amount = '$payment_amount' AND id = '$id' ");
$row = mysql_fetch_row($amount_data);
echo $row[0];
Check the link http://php.net/manual/en/function.mysql-fetch-row.php