This is my first time setting up PayPal's IPN verification code.
The skeleton script I have is working OK, I now need to put in my code. I'm trying to write to a db the verified transaction data. First, should I be using _$post? (I'm getting an error in my sql.)
Also, I'm trying to only add to the db if the record isn't already there. Is my for loop right? I couldn't figure out how to check that $num == 0 (got syntax error).
Thanks!
include "conndb.php";
$sql = "SELECT count * FROM `std_notify` WHERE `txn_id` = $txn_id";
$numresults = mysql_db_query($db,$sql,$dbconnect) or die ("Could not execute query. " . mysql_error());
$num=mysql_num_rows($numresults);
for ($i = 0; $i == $num;){
$item_name = addslashes($item_name);
$txn_id = addslashes($txn_id);
$query = "insert into std_notify values (
\"$item_name\",
\"$txn_id\")";
$result = mysql_query($query);
if ($result){
echo '<br><font size="2">';
echo mysql_affected_rows()." record inserted into database.";
}
}