Jump to content
StudioWeb Forums

Simple PHP Login System: Registration Error ( Notice: Only variables should be passed by reference )


Recommended Posts

I had a difficult time solving this bug, and finally solved it.  I'm posting it here to help others who might be struggling with the same situation. 

Code Source:

This code is from the Simple PHP Login System, Lesson 17 & 18.  

My Setup:

  • Machine: Windows 10
  • WAMP
  • PHP version: 7.4.9
  • Code Editor: VS Code

Here is my error notice:

Notice: Only variables should be passed by reference in C:\wamp64\www\phplogin-parts17-18-projectfiles\register.php on line 144

I got that error message when I tried to register a member.

The problem lies in LINE 144

Screenshot-1.png

SOLUTION:

 You need to create a new variable that represents...
 
      md5($input['pass'. $config['salt'])
 
 Let's call that variable $salty....
 
      $salty = md5($input['pass'. $config['salt']);
 
...and then insert that new variable $salty into ... $stmt->bind_param(x, x, x, x, $salty);
 
The code should look like this:
 
     if ($stmt = $mysqli->prepare("INSERT members (username, email, typepasswordVALUES (?,?,?,?)"))
     {
         $salty = md5($input['pass'. $config['salt']);
         $stmt->bind_param("ssss"$input['user'], $input['email'], $input['type'], $salty);
         $stmt->execute();
         $stmt->close();
 
 
 
 
 
 

 

Hope that helps!

Stephen

Edited by StephenMBassett
Clarification
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...