Code: Select all
<?php
$title = $_POST['title'];
$blurb = $_POST['blurb'];
$blog = $_POST['blog'];
$num = $_POST['number'];
$safetitle = str_replace("'", "~", $title);
$safeblurb = str_replace("'", "~", $blurb);
$safeblog = str_replace("'", "~", $blog);
$con = mysql_connect("login into here obviously.");
if(!$con) {
die("Could not Connect: " .mysql_error());
}
@mysql_select_db("blog_db") or die("Unable to select database " .mysql_error());
$result = mysql_query("UPDATE blogs SET title=$safetitle WHERE blogID=$num") or die("title UPDATE error: " . mysql_error());
$result2 = mysql_query("UPDATE blogs SET blurb=$safeblurb WHERE blogID=$num") or die("Blurb UPDATE error: " . mysql_error());
$result3 = mysql_query("UPDATE blogs SET content=$safeblog WHERE blogID=$num") or die("Content UPDATE error: " . mysql_error());
?>
<html>
<body>
<?
$newquery = mysql_query("SELECT * FROM blogs WHERE blogID = '$num'") or die("Could not re-SELECT stuff: " .mysql_error());
while($row = mysql_fetch_array($newquery)) {
$newtitle = $row['title'];
$newblurb = $row['blurb'];
$newblog = $row['content'];
}
$snewtitle = str_replace("~", "'", $newtitle);
$snewblurb = str_replace("~", "'", $newblurb);
$snewblog = str_replace("~", "'", $newblog);
?>
<p align="center">Your blog has been updated.<br /> The new title is: <?php echo $snewtitle ?><br />Your new blurb is: <?php echo $snewblurb ?><br />And your new blog is: <?php echo $snewblog ?></p>
<a href="test-edit.php">Click</a> to edit another blog   |   <a href="/">Click</a> to go back to your home page.
</body>
</html>