title: PHP and MySQLi - Cannot pass parameter 2 by reference in
body: <p>I am trying to make a function which will check update and insert some data but I am having an issue in the first step where the $stmt-&gt;bind_param is saying that is not passing parameters by reference or something like that.</p>
  <p>I have attached below the function code:</p>
  <pre><code>public function killTarget($killerid,$victimiid,$victimcode)
      {
  
          if ($this-&gt;checkUsercode($victimcode,$victimiid))
          {
              $stmt = $this-&gt;_db-&gt;prepare(&quot;UPDATE users SET status =? WHERE user_id =?&quot;);
              $stmt-&gt;bind_param(&quot;ii&quot;,0,$victimiid);
  
              if ($stmt-&gt;execute())
              {
                  $stmt-&gt;store_result();
                  $stmt-&gt;fetch();
  
                  $stmt = $this-&gt;_db-&gt;prepare(&quot;SELECT victim_id FROM target WHERE killer_id = ?&quot;);
                  $stmt-&gt;bind_param(&quot;i&quot;,$victimiid);
  
                  if ($stmt-&gt;execute())
                  {
                      $stmt-&gt;store_result();
                      $stmt-&gt;bind_result($targetid);
                      $stmt-&gt;fetch();
  
                      $stmt = $this-&gt;_db-&gt;prepare(&quot;INSERT INTO target (killer_id, victim_id) VALUES (?,?)&quot;);
                      $stmt-&gt;bind_param(&quot;ii&quot;,$killerid,$targetid);
  
                      if ($stmt-&gt;execute())
                      {
                          $stmt-&gt;store_result();
                          $stmt-&gt;fetch();
                          $stmt-&gt;close();
                      }
                  }
              }
              else
              {
                  Main::setMessage(&quot;targets.php&quot;,$this-&gt;_db-&gt;error,&quot;alert-error&quot;);
              }
          }
  
      }
  </code></pre>