Mysql DB无法正确更新

时间:2014-01-06 16:52:31

标签: php mysql

我确定我遗漏了一些非常简单的东西我已多次运行mysql更新脚本但是这个不会工作,我不明白为什么。 当点击更新按钮时,我将数据从数据库调用到ckeditor文本框这个脚本运行我得到成功消息但数据库没有更新我错过的内容???

session_start();
include ("mysql-connect.php");
include ("check-login.php");
if(isset($_POST['editblogbody'])){
      if($_POST['editblogbody'] != "" && $_POST['editblogtitle'] != "" && $_POST['blog_id'] != ""){
          $title = $_POST['editblogtitle'];
          $body = $_POST['editblogbody'];
          $bid = $_POST['blog_id'];
          $sql = mysql_query("UPDATE blogs SET title='$title', body='$body' WHERE id='$bid'")or die (mysql_error());    
          echo '<img src="../_Images/round_success.png" alt="Success" width="31" height="30" />Success 1';  
          exit();            
      }
      else{
          echo '<img src="../_Images/round_success.png" alt="Success" width="31" height="30" />Success 2';  
          exit();
      }
}
else{
    echo '<img src="../_Images/round_error.png" alt="Error" width="31" height="30" /> &nbsp; Opps something went wrong. Please Try again.'; 
    exit();
}   

发布表单的脚本

$('#editblog').on('submit', function (e) {
    e.preventDefault();
    $('input[type=submit]', this).attr('disabled', 'disabled');
    var blogTitle = $("#editblogtitle").val();
    var blogText = CKEDITOR.instances['editblogbody'].getData();
    var url = "../_Scripts/edit-blog.php";
    if (!blogTitle) {
        $('input[type=submit]', this).removeAttr('disabled');
        $("#blogeditreply").html('<img src="../_Images/round_error.png" alt="Error" width="31" height="30" /> &nbsp; Please type a Title.').show().fadeOut(6000);
        return false;
    } else if (!blogText) {
        $('input[type=submit]', this).removeAttr('disabled');
        $("#blogeditreply").html('<img src="../_Images/round_error.png" alt="Error" width="31" height="30" /> &nbsp; Please type in your Blog.').show().fadeOut(6000);
        return false;
    } else {
        $("#blogFormProcessGif").show();
        for (instance in CKEDITOR.instances) {
            CKEDITOR.instances['blogbody'].updateElement();
        }
        $.post(url, $('#editblog').serialize(), function (data) {
            $("#jqueryReply").html(data).show().fadeOut(6000);
            $("#blogFormProcessGif").hide();
            $.modal.close();
        });
    }
});

连接就是这样的

define('HOSTNAME','#'); 
define('DB_USERNAME','#'); 
define('DB_PASSWORD','#');
define('DATABASE','#'); 
$link = mysql_connect(constant('HOSTNAME'), constant('DB_USERNAME'), constant('DB_PASSWORD')) or die("Database connection error, please check!"); mysql_select_db(constant('DATABASE'), $link) or die("Connection to the defined database not possible, please check!");

我可以很好地回应所有的变量,所以所有信息都在那里

由于

2 个答案:

答案 0 :(得分:0)

你得到哪个成功答案? “成功1”或“成功2”

答案 1 :(得分:0)

我错过了很简单的对不起大家:(

$('#editblog').on('submit', function (e) {
    e.preventDefault();
    $('input[type=submit]', this).attr('disabled', 'disabled');
    var blogTitle = $("#editblogtitle").val();
    var blogText = CKEDITOR.instances['editblogbody'].getData();
    var url = "../_Scripts/edit-blog.php";
    if (!blogTitle) {
        $('input[type=submit]', this).removeAttr('disabled');
        $("#blogeditreply").html('<img src="../_Images/round_error.png" alt="Error" width="31" height="30" /> &nbsp; Please type a Title.').show().fadeOut(6000);
        return false;
    } else if (!blogText) {
        $('input[type=submit]', this).removeAttr('disabled');
        $("#blogeditreply").html('<img src="../_Images/round_error.png" alt="Error" width="31" height="30" /> &nbsp; Please type in your Blog.').show().fadeOut(6000);
        return false;
    } else {
        $("#blogFormProcessGif").show();
        for (instance in CKEDITOR.instances) {
////////////////////////////////////////////////////////////////////////
//////////Forgot to change the editor instance here/////////////////////
            CKEDITOR.instances['blogbody'].updateElement();
////////////////////////////////////////////////////////////////////////
        }
        $.post(url, $('#editblog').serialize(), function (data) {
            $("#jqueryReply").html(data).show().fadeOut(6000);
            $("#blogFormProcessGif").hide();
            $.modal.close();
        });
    }
});

抱歉在代码中添加了评论。我忘了更改脚本底部的ckeditor实例