Updating SQL database value in PHP script
I have an IPN script that is doing some work on the amount of a payment received, and when a certain amount is received, it is updating their license code in the database after verifying it with PayPal's IPN service.
This SQL isn't right, it's not updating. The rest of my code is fine because it sends an email, but where's the SQL error at? It's really late and I'm spacing out...
开发者_Go百科if ($amt == "77.00")
{
mysql_query("UPDATE login_users SET license_code = 3 WHERE username = ". $username ."") or die(mysql_error());
// Change license code in database
}
You need quotes around the user name if it's a string.
WHERE username = '". $username ."'
Also make sure $username
is properly sanitized:
$username = mysql_real_escape_string(... wherever the value is coming from ...);
Put SET
before WHERE
and add single quotes around username
"UPDATE login_users SET license_code = 3 WHERE username = '". $username ."'";
精彩评论