在页面上保持会话

时间:2012-03-27 14:06:44

标签: php mysql

我有一个用户登录的myaccount页面。由此,用户可以单击另一个表单“语言”表。提交后,将其带回他们的帐户。这是我到目前为止的代码,但得到错误Parse错误:语法错误,意外'='。     

if (!empty($_POST['doLanguage']) && $_POST['doLanguage'] == 'Submit') 
 { 
  foreach($_POST as $key => $value) 
   id = '$_SESSION[user_id]';

$host  = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');


(empty($err)) {
for($i = 0; $i < count($_POST["other"]); $i++)
{
  $native = mysql_real_escape_string($_POST['native'][$i]);
  $other = mysql_real_escape_string($_POST['other'][$i]);
  $other_list = mysql_real_escape_string($_POST['other_list'][$i]);
  $other_read = mysql_real_escape_string($_POST['other_read'][$i]);
  $other_spokint = mysql_real_escape_string($_POST['other_spokint'][$i]);
  $other_spokprod = mysql_real_escape_string($_POST['other_spokprod'][$i]);
  $other_writ = mysql_real_escape_string($_POST['other_writ'][$i]);

  $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]
        )
        ";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());     
    }


echo('<a href="myaccount.php?id=' . $_SESSION['id'] . '">link</a>');
exit();

 } 
}

请帮忙!

1 个答案:

答案 0 :(得分:4)

id = '$_SESSION[user_id]';更改为$id = $_SESSION['user_id'];