0

I have a simple SQL statement where I am biding variables and it is not binding. The values work when hard coding them in the update statement but do not work when I bind them:

if(isset($_GET["coachUpdate"])) {
    if ($pdoLink = \Database::GetInstance()->GetPDO()) {
        $updateQuerySQL = "UPDATE Registration SET Coach = :coach WHERE Reg = :reg";
        if ($updateQuery = $pdoLink->prepare($updateQuerySQL)) {
            $bindValues = "";

            $bindValues[":reg"] = $_GET["Reg"];
            $bindValues[":coach"] = $_GET["Coach"];

            if ($updateQuery->execute($bindValues)) {
                if ($query->rowCount()) {
                    echo $updateQuerySQL;
                }
            }
        } else {
            echo "Registration update query prep failed.<br />";
        }
    }
}
Qirel
  • 25,449
  • 7
  • 45
  • 62
sjw0525
  • 329
  • 2
  • 17
  • 3
    because you have not formatted your code properly, the mighty PHP hammer wielding thor has decided this should be your fate – e4c5 Nov 22 '16 at 00:31
  • 3
    `var_dump($bindValues)` what does it contain? – Qirel Nov 22 '16 at 00:32
  • You have not posted your real code because this will produce an error `$bindValues = ""; $bindValues[":reg"] = $_GET["Reg"];` – e4c5 Nov 22 '16 at 01:44
  • What's wrong with: $bindValues = ""; $bindValues[":reg"] = $_GET["Reg"]; – sjw0525 Nov 22 '16 at 02:15
  • Going from a string to an array is not the problem. I see that it should be $bindValues = []; That way I am not going from a string to an array. I cbhanged that and it still is not binding – sjw0525 Nov 22 '16 at 03:06

0 Answers0