我试图进入某个表格,我得到了一般的错误。这是我的代码,如下所示。
注意:我在另一个更新查询中使用了这个连接,它工作正常。
另一件事,bindParam()和bindValue()之间的区别是什么?
$query = $dbh->query("INSERT INTO music SET
uid = ?, title = ?,
album = ?, artist = ?,
year = ?, genre = ?,
albumart = ?, audio = ?,
time = ?, perms = ?
");
$query->bindParam(1, $uid);
$query->bindParam(2, $title);
$query->bindParam(3, $album);
$query->bindParam(4, $artist);
$query->bindParam(5, $year);
$query->bindParam(6, $genre);
$query->bindParam(7, $art);
$query->bindParam(8, $song);
$query->bindParam(9, now());
$query->bindParam(10, $download);
$query->execute();
$check_exc = $query->execute();
if ($check_exc) {
$new_id = $dbh->lastInsertId('sid');
感谢。
答案 0 :(得分:0)
prepare
代替query
来电。mysqli
。bindParam
和bindValue
之间的差异,previous duplicate存在。$query = $dbh->prepare("INSERT INTO music SET
uid = ?, title = ?,
album = ?, artist = ?,
year = ?, genre = ?,
albumart = ?, audio = ?,
time = ?, perms = ?");
if( !$query ) {
die( print_r($dbh->errorInfo()) );
}