1

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

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
    } 
1
  • You forgot quotes around " . $username . ". You have to put them if you want your variable to be considered as a string. Commented Aug 11, 2011 at 7:24

2 Answers 2

2

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 ...);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Pekka, your answer worked straight out of the box. And yes, regardless that it's been verified with Paypal I should probably do that, thanks a lot.
0

Put SET before WHERE and add single quotes around username

"UPDATE login_users SET license_code = 3 WHERE username = '". $username ."'";

1 Comment

Just updated my code above, Dreamweaver says no syntax errors with mine, had to add a trailing " to yours because it's appending a variable, but it's not updating still for some reason...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.