我收到这个错误:
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] . ")"
这是让我悲伤的最后一行! 任何帮助都会很棒!
最佳答案
您忘记了最后一行查询中的 $,就在 user_id 之前。
$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] . ")"
编辑: 'user_id' 而不是 $user_id 更有意义:)
关于php - 通知 : Use of undefined constant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9898304/