我想从数据库中查看特定的用户信息。但是我收到了这个错误

时间:2017-09-23 22:30:35

标签: php

if(isset($_GET['view_id']) && !empty($_GET['view_id'])){$id = $_GET['view_id'];

$stmt_edit = $DB_con->prepare('SELECT date_of_birth, phone_number,hostel_address, name_of_sponsors,phone_number_of_sponsors, gender,department, first_name, last_name, user_email, user_name, user_pass, FROM `100`WHERE user_id =:uid');
$stmt_edit->execute(array(':uid'=>$id));
$edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC);
extract($edit_row);}else{
header("Location: index.php");}

它向我展示了这些错误:

  

致命错误:未捕获的异常' PDOException' with message' SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以便在' FROM 100附近使用正确的语法WHERE user_id =' 19''在第3行'在第15行的C:\ wamp \ www \ registration \ admin \ levels \ 100level \ view.php

     

(!)PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;查看与您的MySQL服务器版本相对应的手册,以便在' FROM 100附近使用正确的语法WHERE user_id =' 19''

1 个答案:

答案 0 :(得分:1)

在导致SQL语法错误的user_pass之后,您有更多“,”,您的查询必须是:

SELECT date_of_birth, phone_number,hostel_address, name_of_sponsors,phone_number_of_sponsors, gender,department, first_name, last_name, user_email, user_name, user_pass FROM `100` WHERE user_id =:uid