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 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题