简体   繁体   English

这个查询有什么问题

[英]What's wrong in this query

if (!empty($_POST['comment']))
 {
       mysql_query("UPDATE contacts SET opp=1, SET inforecall='"$_POST['comment']"' WHERE contact_id='"$_GET['id']"' ");

}

Your first problem is lack of concatenation operators, change: 您的第一个问题是缺少串联运算符,请更改:

"UPDATE contacts SET opp=1, SET inforecall='"$_POST['comment']"' WHERE contact_id='"$_GET['id']"' ";

to: 至:

"UPDATE contacts SET opp=1, inforecall='" . $_POST['comment'] . "' WHERE contact_id='" . $_GET['id'] . "' ";

replace your code with this 用这个替换你的代码

    if (!empty($_POST['comment']))

    {

    $id=$_GET['id'];

    $comment=$_POST['comment'];

    $query="UPDATE contacts SET opp=1, SET inforecall='$comment' WHERE contact_id='$id'";
               mysql_query($query);
}

Don't repeat SET . 不要重复SET It's just 只是

UPDATE tablename SET col1=val1, col2=val2 WHERE condition;

You should not give multiple SET keyword against each fieldname - The proper code should be: 您不应针对每个字段名称使用多个SET关键字-正确的代码应为:

if (!empty($_POST['comment'])) {
  mysql_query("UPDATE contacts SET opp=1, inforecall='"$_POST['comment']"' WHERE ontact_id='"$_GET['id']"' ");
}
if (!empty($_POST['comment']))
{
       mysql_query("UPDATE contacts SET opp=1, inforecall='{$_POST['comment']}' WHERE contact_id='{$_GET['id']}'");
}

That should solve your problems. 那应该解决您的问题。 If your contact_id is an INT then remove both of the single quotes after its equal sign. 如果您的contact_id是INT,则在等号后删除两个单引号。

首先,您不应该两次设置SET,而只需

UPDATE contacts SET opp=1, inforecall=...

First of all there are two set in the query, secondly there is an error in the syntax ( the php code $_post and $_get should be concatinated along with rest of the string and there are both get and post method used in the same place which are not sent at the same time.if you use post for both Maybe this will work, 首先在查询中有两个设置,其次是语法错误(PHP代码$ _post和$ _get应该与字符串的其余部分一起使用,并且get和post方法都在同一位置使用不能同时发送。如果您同时使用post和post,则可能会起作用,

if (!empty($_POST['comment']))
 {
       mysql_query("UPDATE contacts SET opp=1,inforecall='".$_POST['comment']."' WHERE contact_id='".$_POST['id']."' ");

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM