-2

EDIT: Fixed, something went wrong with some variables, works fine now!

Working code:

if($q = $this->pdo->prepare("UPDATE `ba_keys` SET `times_used` = :used WHERE `betacode` = :beta"))
    {
        $q->bindValue(':used', 90);
        $q->bindValue(':beta', $betacode);
        if($q->execute())
        {
            return 'Execution done.';
        } else {
            return 'Execution failed.';
        }
    } else {
        return 'Query preparing failed.';
    }
Community
  • 1
  • 1
Dexvi
  • 9
  • 2

1 Answers1

1

You do not need single quotes in the Prepared Statement. PDO will handle that for you. Your code should be:

$q = $this->pdo->prepare("UPDATE `ba_keys` SET `times_used` = :used WHERE `betacode` = :beta");
$q->bindValue(':used', 90);
$q->bindValue(':beta', $betacode);
$q->execute();

You might also wish to consider returning the result of $q->execute() from your function, for completeness.

BenM
  • 52,573
  • 26
  • 113
  • 168