请尝试从 mysqli 移动到 pdo 但运行此代码
<?php
$sql = "select concat(register.fname ,' ' ,register.lname) as name,register.matric as matric,register.username as uname,register.sex as sex,register.phone as phone ,register.passport as passport ,register.email as email,register.level as level,faculty.fac_name as fac,dept.dept_name as dept,diary.diary as diary,diary.date_added as added from register,faculty,dept,diary where register.user_id = :_id and diary.username = :name limit 1";
$sth = $dbh->prepare($sql);
$sth->bindValue(':id', $id, PDO::PARAM_INT);
$sth->bindParam(':name', $username);
$sth->execute();
?>
它显示此错误(!)警告:PDOStatement::bindValue() [pdostatement.bindvalue]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\wamp\www\uni\det\viewuser.php on第 14 行