0

I'm trying to get a registration form to work and when I put in my user, pw and email I get 3 lines of error.

    $query = $this->db->prepare($sql);
    $query->bindParam(':name', $user->get("name")); ERROR HERE
    $query->bindParam(':email', $user->get("email")); ERROR HERE
    $query->bindParam(':pw', $user->get("password")); ERROR HERE
    try {
        $out = $query->execute();
    } catch (Exception $e){
        $out = false;
    }
    return $out;

Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\XXX\classes\User_Table.class.php on line 13

Thanks in advance!

SmalliSax
  • 342
  • 3
  • 6
  • 24

1 Answers1

0
$query->bindParam(':name', $user->get("name")); //ERROR HERE

You must put the data into a variable, before passing it to the function, requiring a reference as a parameter. Like this:

$variable = $user->get("name");
$query->bindParam(':name', $variable); //NO ERROR HERE

Here is the explanation, what can be passed by reference: http://www.php.net/manual/en/language.references.pass.php

user4035
  • 22,508
  • 11
  • 59
  • 94