PHP error: quot;Cannot pass parameter 2 by referencequot;(PHP 错误:“无法通过引用传递参数 2)
问题描述
我只是需要帮助解决这个我不太明白的 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:
$a = 0;
$update->bind_param("is", $a, $selectedDate); //LINE 13
如果您想了解正在发生的事情,而不是仅仅修复您的致命错误
,请阅读以下内容:http://php.net/manual/en/language.references.pass.php
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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 错误:“无法通过引用传递参数 2"


基础教程推荐
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01