我收到此错误:注意:使用未定义的常量
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