php - Mysql 数据库未正确更新

标签 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!");

我可以很好地回显所有变量,因此所有信息都在那里

谢谢

最佳答案

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

关于php - Mysql 数据库未正确更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20955011/

相关文章:

php - 从 View 中的表单读取文件输入时总是出错

php - 您如何使调试代码远离生产环境?

MySQL 如何更正此子查询?

php - mysql_fetch_array 出错

php - 显示一次选择自动完成jquery的人的信息

php - 使用 LLVM API 将全局字符串存储在可变变量中

mysql - 如何在 SELECT 上将 unsigned int 乘以 -1?

mysql - 快速 MYSQL 查询删除重复项

mysql - 在日期时间字段中设置当前日期

java - 删除 HQL 中带有 where 子句的查询