我收到此錯誤:注意:使用未定義的常量
Notice: Use of undefined constant user_id - assumed 'user_id'
in C:\xampp\htdocs\euisample\language.php on line 44
我想我已經用這個定義它:
$id= " . $_SESSION[user_id] . ";
這是SQL語句;
$sql_insert = "INSERT into `language`
(`native`,`other`,`other_list`,`other_read`, `other_spokint`
,`other_spokprod`,`other_writ` )
VALUES
('$native','$other','$other_list','$other_read','$other_spokint','$other_spokprod',
'$other_writ') WHERE id= " . $_SESSION[user_id] . ")"
這是最後一行那給我悲憤! 任何幫助將是偉大的!
使用'$ _SESSION [USER_ID]'應該是'$ _SESSION [ 'user_ID的']'。解析器將檢查'[]'中的值是否是一個定義的常量(如果它未包含在引號中)。這就是爲什麼它提出了一個通知。在編寫生產應用程序之前,請閱讀一本書或遵循一些權威性教程。你也必須注意SQL注入。 – Shef 2012-03-27 21:58:52
以下是手冊條目:[爲什麼*'$ foo [bar]'*錯誤?](http://www.php.net/manual/en/language.types.array.php#language.types.array。 don) – cmbuckley 2012-03-27 22:14:32