Ok So I have a function that is executed after a customer purchases a digital code. The function is very simple and uses pdo after I thought that would fix it instead of using mysqli. everything works but the username variable does not get put in the table even thought I can echo it out and use it in other sql command just fine but for some reason not this particular line.
Here is the code:
function redeemToken($amount = 1){
$db_tokens = new PDO('mysql:host=IP;dbname=DB', "U", "P");
$qOne = $db_tokens->query("SELECT * FROM tokens WHERE used='0' LIMIT $amount;"); //selects the first unused token
$dataToken = $qOne->fetch();
$token = $dataToken["token"];
$qTwo = $db_tokens->query("UPDATE tokens SET used='1', usedby='".$php_session_username."', date_used=NOW() WHERE token='".$token."';"); //uses the token for the current logged in user
$db_kvs = null;
}
As I stated everything is executed fine except for the fact that the username value ($php_session_username) does not get added into the table. but when echo'd out shows the logged in users name clearly as well as with any other sql command I run on that page; it works fine.
Any help would be much appreciated so thanks in advance.