PHP MySQL UPDATE query is not updating!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adamjoiner
Forum Newbie
Posts: 8
Joined: Sun Jul 11, 2010 11:57 pm

PHP MySQL UPDATE query is not updating!

Post 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:
DaiLaughing
Forum Commoner
Posts: 76
Joined: Thu Jul 16, 2009 8:03 am

Re: PHP MySQL UPDATE query is not updating!

Post 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.
Post Reply