我是 PHP 的新手,我在尝试在旧的 PHP 应用程序上定义带有参数的简单查询时遇到以下问题。我已经这样做了(模仿这个应用程序中由其他人制作的其他工作查询):
$result_facility_list = $db->prepare("select name from pm_facility where lang = :id_lang");
$result_hotel_file->bindParam(":id_lang", 2);
然后
问题是,当它尝试执行将整数值 2 绑定(bind)到 :id_lang 参数的第二行时,我收到此错误消息:
( ! ) Fatal error: Cannot pass parameter 2 by reference in C:\xampp\htdocs\BeTrivius-Panda\templates\default\models\booking.php on line 534
Call Stack
# Time Memory Function Location
1 0.0326 165272 {main}( ) ..\index.php:0
2 8.2043 835656 include( 'C:\xampp\htdocs\BeTrivius-Panda\templates\default\models\booking.php' ) ..\index.php:146
可能是什么问题?我错过了什么?我该如何解决这个问题?
最佳答案
改变这一行
$result_hotel_file->bindParam(":id_lang", 2);
到
$id=2;
$result_hotel_file->bindParam(":id_lang", $id);
因为您需要将值作为变量传递给 bindparam
关于php - 为什么我尝试在这个旧的 PHP 应用程序中定义带有参数的查询时出现此错误? ( fatal error : Cannot pass parameter 2 by reference in. ..),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43169270/