Killersites Community: "Variables should be passed by reference" PHP Login Course Error - Killersites Community

Jump to content

Subscribe to My KillerSites Screencast Blog        RSS Feed

"Variables should be passed by reference" PHP Login Course Error

Leave Comment
A couple people have mentioned this, so I thought I should post a blog entry on it so I can point people here is more people have trouble...

OOP Version

Specifically, when PHP's error reporting is set to "Strict", you'll get this error when following along with my code:

Strict standards: Only variables should be passed by reference in [path to the source code]\models\m_auth.php on line 31

I'm not sure if this error is something new, but this error wasn't something that I ran into when creating or testing the series. However, here are a couple ways to fix it:

  • Update your PHP.ini file to change the error reporting settings or turn off strict error reporting using PHP code: http://php.net/manua...r-reporting.php
  • Alternately, you can update the code itself to fix this, by changing this line in the m_auth.php file:

    $stmt->bind_param("ss", $user, md5($pass . $this->salt));

    to

    $pw = md5($pass . $this->salt);
    $stmt->bind_param("ss", $user, $pw); 


Non-OOP Version

Specifically, when PHP's error reporting is set to "Strict", you'll get this error when following along with my code:

Strict standards: Only variables should be passed by reference in [path to source code]\login.php on line 46

This issue also occurs on the non-OOP version of the PHP login course, and here's the fix. You can change your PHP error settings as I indicated above, or change this line in login.php:

$stmt->bind_param("ss", $input['user'], md5($input['pass'] . $config['salt']));

to

$pw = md5($input['pass'] . $config['salt']);
$stmt->bind_param("ss", $input['user'], $pw);

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

May 2013

S M T W T F S
   1234
567891011
12131415161718
192021222324 25
262728293031 

Recent Entries