Hi, this is part of a script used to verify paypal payments and update a mysql database if the payment is verified. I had it working in a separate mysql table but I have now changed the table and it doesn't seem to be working.

When the verification from paypal comes back there is already some info in the mysql table and the item number should match the gigname and so if that is the case I want the info from paypal to be inserted in that row.

However the fields that are updated by the updatePayments function are empty, so should I be using insert?

At the moment no info from paypal is entered into gigs, not even on a separate row, could anyone tell me why?

<?php
// functions.php
function check_txnid($tnxid){
    global $link;
    return true;
    $valid_txnid = true;
    //get result set
    $sql = mysql_query("SELECT * FROM `gigs` WHERE txnid = '$tnxid'", $link);       
    if($row = mysql_fetch_array($sql)) {
        $valid_txnid = false;
    }
    return $valid_txnid;
}



function updatePayments($data){ 
    global $link;
    if(is_array($data)){                
        $sql = mysql_query("UPDATE `gigs` SET (txnid, payment_amount, payment_status, itemid, createdtime) VALUES (
                '".$data['txn_id']."' ,
                '".$data['payment_amount']."' ,
                '".$data['payment_status']."' ,
                '".$data['item_number']."' ,
                '".date("Y-m-d H:i:s")."' 
                ) WHERE gigname = '".$data['item_number']."'" , $link);
    return mysql_insert_id($link);
    }
}
?>

Thanks in advance

Member Avatar for diafol

return true; stop further code execution in the function.

Could try this:

    if(is_array($data)){
        $d = array_map('mysql_real_escpae_string',$data);
        extract($d);                
        $sql = mysql_query("UPDATE `gigs` 
            SET 
                (`txnid`, `payment_amount`, `payment_status`, `itemid`, `createdtime`) 
            VALUES
                ('$txn_id','$payment_amount','$payment_status','$item_number','".date('Y-m-d H:i:s')."')
            WHERE `gigname` = '$item_number'", $link);

        return mysql_insert_id($link);
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.