我可能只是太愚蠢而无法看到它,但这是我的问题:
代码:
$stmt = $mysql->prepare("INSERT INTO projects_files (mid,filename,type) VALUES ('?','?','?')");
$stmt->bind_param('isi',$this->id,$File->filename,$File->type);
错误:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
我已经检查过所有vars都已分配并且有一个值且数据类型是正确的。
提前感谢您的帮助
答案 0 :(得分:1)
请勿将问号放在引号中。数据库将适当地引用所有内容。
$stmt = $mysql->prepare("INSERT INTO projects_files (mid,filename,type) VALUES (?,?,?)");
$stmt->bind_param('isi',$this->id,$File->filename,$File->type);
答案 1 :(得分:1)
删除问号(bindparam
)周围的'
单引号(?
)
$stmt = $mysql->prepare("INSERT INTO
projects_files (mid,filename,type)
VALUES (?,?,?)");
$stmt->bind_param('isi',$this->id,$File->filename,$File->type);