检查代码是否正确地使用了bind_param函数。确保绑定的参数类型、数量和顺序正确无误。另外,使用bind_result()方法来指定结果集中每个字段的变量,并使用fetch()方法获取结果集中的每一行数据。
以下是使用bind_param(), bind_result()和fetch()函数的示例代码:
$stmt = $mysqli->prepare("SELECT id, name FROM table WHERE age > ?"); $stmt->bind_param("i", $age); $age = 18; $stmt->execute(); $stmt->bind_result($id, $name);
while ($stmt->fetch()) { echo "ID: {$id}, Name: {$name}"; }
$stmt->close();