Page 1 of 1

PHP MySQL UPDATE query is not updating!

Posted: Wed Jul 21, 2010 9:50 pm
by adamjoiner
in my paypal ipn_response.php I call this function:

Code: Select all

$amount = (int)"3.00";
$paypal_ipn->pay_instructor($amount);   

This function is specified in an 'included' class file as such:

Code: Select all

function pay_instructor($amount){
// aj - Add commission to referring instructors account in com_profiler table
$qry = "UPDATE jos_comprofiler SET accountbal = accountbal + ". $amount ." WHERE id = '" . $_COOKIE['refidC'] . "'";
mysql_query($qry);
}
As far as I can tell, everything is correct... Just to be sure I tried calling the function in another php file (my registration page) and it updated fine. Any suggestions?? :banghead:

Re: PHP MySQL UPDATE query is not updating!

Posted: Thu Jul 22, 2010 6:49 am
by DaiLaughing
Presumably you have ECHOed the variable to check the contents are correct. Is your table field the right type? Personally I would write your query like this as I find it clearer (I would transfer the COOKIE data to a normal variable first):

Code: Select all

$qry = "UPDATE jos_comprofiler SET accountbal = accountbal + $amount WHERE id = '$refidC';";
Then extend your next line:

Code: Select all

mysql_query($qry) or die("Query to update the account balance failed with this err: ".mysql_error());
Then you will get a message (unless errors are turned off) which tells you what the problem is. Remember to remove the OR DIE bit before deploying the page to users.