准备好的语句给出错误

Prepared statement giving error

我错过了什么?

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

$name = 'Samuel "L" Jackson';

$conn = new mysqli($servername, $username, $password, $dbname);
$stmt = $conn->prepare("INSERT INTO test2 (id, name) VALUES (?,  
?)");
$stmt->bind_param("is",'600' , $name);

$stmt->execute();
$stmt->close();
$conn->close();
?>

我收到以下错误:
无法在 C.... 中通过引用传递参数 2 ...

bind_param 接受两个或更多参数。第一个必须是一个字符串,用于标识 SQL 参数的数据类型。 The rest of the arguments must be variables that can be passed by reference'600' 是常量,因此不能通过引用传递它。

只需使用一个临时变量来解决该限制,如下所示:

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

$id = 600;
$name = 'Samuel "L" Jackson';

$conn = new mysqli($servername, $username, $password, $dbname);
$stmt = $conn->prepare("INSERT INTO test2 (id, name) VALUES (?, ?)");
$stmt->bind_param("is", $id, $name);

$stmt->execute();
$stmt->close();
$conn->close();
?>