Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php脚本没有';t使用ajax调用执行_Php_Mysql_Ajax - Fatal编程技术网

php脚本没有';t使用ajax调用执行

php脚本没有';t使用ajax调用执行,php,mysql,ajax,Php,Mysql,Ajax,我需要你的帮助 我有一些像这样的按钮输入 <input type="text" name="cmsperso" id="cmsperso" /> <input type="text" name="chefdequart" id="chefdequart" /> <input type="text" name="adjoint" id="adjoint" /> <button type="submit" name="perso" onClick="pers

我需要你的帮助

我有一些像这样的按钮输入

<input type="text" name="cmsperso" id="cmsperso" />
<input type="text" name="chefdequart" id="chefdequart" />
<input type="text" name="adjoint" id="adjoint" />
<button type="submit" name="perso" onClick="perso()">envoyer</button>
在我的perso.php中,我有这个更新

$cnx = mysql_connect( "localhost", "root", "" );
$db = mysql_select_db( "maincourante" );
$req = mysql_query("SELECT idops FROM ops ORDER BY idops DESC LIMIT 1");
$data = mysql_fetch_array($req);

$cmsperso = $_POST["cmsperso"];
$chefdequart = $_POST["chefdequart"];
$adjoint = $_POST["adjoint"];

$perso = utf8_decode("UPDATE `Opérations n°".$data['idops']."` SET cmsperso='$cmsperso', chefdequart='$chefdequart', adjoint='$adjoint'");

mysql_query($perso, $cnx) or die(mysql_error());
mysql_close();
除更新外,一切正常。在phpmyadmin中,没有任何值被更新

$cnx = mysql_connect( "localhost", "root", "" );
$db = mysql_select_db( "maincourante" );
$req = mysql_query("SELECT idops FROM ops ORDER BY idops DESC LIMIT 1");
$data = mysql_fetch_array($req);

$cmsperso = $_POST["cmsperso"];
$chefdequart = $_POST["chefdequart"];
$adjoint = $_POST["adjoint"];

$perso = utf8_decode("UPDATE `Opérations n°".$data['idops']."` SET cmsperso='$cmsperso', chefdequart='$chefdequart', adjoint='$adjoint'");

mysql_query($perso, $cnx) or die(mysql_error());
mysql_close();

请帮助

您的帖子中没有发送变量值

function perso() {
$.ajax({
  type: "POST",
  url: "form/perso.php",
});}
需要将变量和值添加到此调用,如下所示:

function perso() {
$.post("form/perso.php", { adjoint: $("#adjoint").val(), cmsperso: $("#cmsperso").val(), chefdequart: $("#chefdequart").val() } );
});}
另外,还可以看看如何管理数据对象,因为查询可以被注入其中

最后,您似乎没有
where
子句,这意味着表中的所有行都将被更新,这可能不是您想要的


另一个我想我会考虑给你的表命名比现在有空格和特殊字符的更简单的是在自找麻烦。

你确定<代码> OpReices n°吗?“$DATA(IDOPS)”。“< /代码>是你正试图更新的正确的表?< /P> < P>早上好,

我想,我部分解决了我的问题

这是我的密码

function getXMLHttpRequest() {
var xhr2 = null;

if (window.XMLHttpRequest || window.ActiveXObject) {
    if (window.ActiveXObject) {
      try {
        xhr2 = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e) {
        xhr2 = new ActiveXObject("Microsoft.XMLHTTP");
      }
    } 
    else {
      xhr2 = new XMLHttpRequest();
    }
  } 
  else {
    alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
    return null;
  }
  return xhr2;
}

/* ressources */
function perso() {
  $.post("form/perso.php", { 
    cmsperso: $("#cmsperso").val(), 
    chefdequart: $("#chefdequart").val(),
    adjoint: $("#adjoint").val()
  });

  var xhr2 = getXMLHttpRequest();

  xhr2.open("POST", "form/perso.php", false);
}
这是firebug的回归


你知道吗?

数据库的插入查询在哪里?所有mysql连接和查询都在哪里?你也有吗?我没有插入查询,只是在这个脚本中更新查询。我有mysql连接。我试图将更新查询替换为插入查询,但它不起作用。您应该在查询周围显示更多上下文(比如您实际执行查询的位置)。另外,您是否返回了特定的MySQL错误?您还意识到更新查询将把表中的所有行都更改为这些值?好的,这将解决实际值,那么
where
子句呢?我不需要指定where子句,因为我只有一个ID,然后我建议进行一些简单的调试。。。在您尝试执行sql查询之前,请先打印出它,并查看它是什么。OK print返回此结果。更新
Op�口粮�1
SET cmsperso='',chefdequart='',adjunct=''因为您没有发送它,所以没有发送,您创建的post命令不知道它来自哪个表单或其中包含哪些变量,您必须指定要发送的数据。您可以打开phpMyAdmin并在其中运行sql查询吗?只需在变量中填入一些测试占位符,看看它是否在那里。只需将下面的内容粘贴进去,看看是否有问题。更新“$data['idops']”。“设置cmsperso='test',chefdequart='test2',adjunct='test3',如果您尚未尝试打印出您发布的变量,请尝试打印,并确保您的变量正确无误。您也可以尝试编辑:mysql_query($perso,$cnx)或die(mysql_error());to:mysql\u query($perso)或die(mysql\u error());因为您在第一次查询中没有使用$cnx。