I'm sure im missing something very simple I have run mysql update scripts many times but this one wont work and I cant understand why. I'm calling data from a DB into a ckeditor text box when the update button is clicked this script runs I get success messages but the DB doesn't update what am I missing???
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" /> Opps something went wrong. Please Try again.';
exit();
}
The script thats post the form
$('#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" /> 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" /> 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();
});
}
});
connection loos like so
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!");
I can echo out all the varibles fine so all the info is there
Thanks