douyou2732 2012-03-27 21:25
浏览 66
已采纳

解析错误:语法错误,意外T_VARIABLE - 分号[关闭]

My IDE is expecting a semicolon but I'm not sure where! It is this line it is highlighting:

,'$other_writ'  WHERE id="$_SESSION[user_id]")

This is the code above:

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

  if(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());     
}

Thanks for any help!

  • 写回答

7条回答 默认 最新

  • dongzaobei0942 2012-03-27 21:30
    关注

    You open a string here:

    "INSERT into `language` ...
    

    and it's being closed here:

    ... WHERE id="
    

    PHP expects a semicolon after this. You could fix it by replacing the double quotes with single quotes (which are the SQL standard), but: why are you using a WHERE clause with INSERT anyway? You don't need that.

    Just finish your string like this:

    ... ,'$other_writ')";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?