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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘