2015-04-01 84 views
0
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '?'"; 
$stmt = $db->prepare($sql); 
$stmt->bind_param("s", $database); 
$stmt->execute(); 
$resultSet = $stmt->get_result(); 

匹配的参数个数它说:“警告:mysqli_stmt :: bind_param():变量数并不在事先准备好的声明匹配的参数个数... “的变量数不准备语句

有人可以解释什么是错的? $数据库是一个字符串。

+0

你必须删除周围的问号单引号。在准备好的声明中不要紧张。 – Jens 2015-04-01 12:11:43

回答

0

如果使用?作为占位符,不要使用蜱'小号

$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = ?"; 
$stmt = $db->prepare($sql); 
$stmt->bind_param('s', $database); 
$stmt->execute(); 
$resultSet = $stmt->get_result(); 
相关问题