2017-09-23 26 views
-1
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");} 

這說明我這些錯誤:我想查看數據庫中的特定用戶信息。但我收到此錯誤

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM 100 WHERE user_id ='19'' at line 3' in C:\wamp\www\registration\admin\levels\100level\view.php on line 15

(!) PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM 100 WHERE user_id ='19''

+1

我不不知道在字段列表中是否可以接受尾隨逗號。另外,你的餐桌真的名爲'100'嗎? –

+0

只要他們返回打勾,數字就可以了@j。 –

回答

0

你有更多的「」 user_pass導致SQL語法錯誤後,您的查詢必須是:

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 
+0

謝謝。爲我工作 –

相關問題