PHP错误:“无法通过引用传递参数2"; [英] PHP error: "Cannot pass parameter 2 by reference"
问题描述
我只需要解决我不太了解的这个PHP错误:
I just need help on this PHP error which I do not quite understand:
致命错误:无法在第13行的/web/stud/openup/inactivatesession.php中通过引用传递参数2
Fatal error: Cannot pass parameter 2 by reference in /web/stud/openup/inactivatesession.php on line 13
<?php
error_reporting(E_ALL);
include('connect.php');
$createDate = mktime(0,0,0,09,05,date("Y"));
$selectedDate = date('d-m-Y', ($createDate));
$sql = "UPDATE Session SET Active = ? WHERE DATE_FORMAT(SessionDate,'%Y-%m-%d' ) <= ?";
$update = $mysqli->prepare($sql);
$update->bind_param("is", 0, $selectedDate); //LINE 13
$update->execute();
?>
此错误是什么意思?该错误如何解决?
What does this error mean? How can this error be fixed?
推荐答案
该错误意味着第二个参数应该是对变量的引用.
The error means that the 2nd argument is expected to be a reference to a variable.
由于您不是处理变量,而是处理值为 0的整数,因此会产生上述错误.
Since you are not handing a variable but an integer of value 0, it generates said error.
要避免这种情况,请执行以下操作:
To circumvent this do:
$update->bind_param("is", $a = 0, $selectedDate); //LINE 13
如果您想了解正在发生的事情,而不是仅仅修复您的Fatal error
,请阅读以下内容:
In case you want to understand what is happening, as opposed to just fixing your Fatal error
, read this: http://php.net/manual/en/language.references.pass.php
这篇关于PHP错误:“无法通过引用传递参数2";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!