Abit messy... anyways, this is my first time I've tried to make a update/editPHP Code:<?php
session_start();
// Set the page title
$title = "Last Entry.com - Add Comment";
// Set the Description Meta Data
$dmeta = "Description Meta Data";
// Set the Keyword Meta Data
$kmeta = "Keyword Meta Data";
// Require the class file
require_once('rf/class.php');
// Require the news paging file
require_once('rf/nps.php');
// Require the header file
require_once('rf/head.php');
// Set variables to a common vars
$cookie_site = $_COOKIE['lastentry'];
$cookie_name = $_COOKIE['lastentry_fname'];
$cookie_blog = $_COOKIE['lastentry_blog'];
$php_self = $_SERVER['PHP_SELF'];
$usrip = getenv("REMOTE_ADDR");
$editReply = $_GET['edit'];
// Connect to MySQL
$db = & new MySQL($host,$dbUser,$dbPass,$dbName);
$dataClean = & new data();
// Check to see if there is a session
if(!isset($_COOKIE['lastentry'])) {
echo "<div class=\"title\">Error!</div>";
echo "<div class=\"normal\">You are not logged in!</div>";
} else {
// send a query to the mySQL database
$gdnps = "SELECT id, author, title, msg, email, DATE_FORMAT(date, '%h:%i - %m.%d.%y') AS fdate, blog";
$gdnps .= " FROM gdnps WHERE id='$id' ";
$result = $db->query($gdnps);
while ($row = $result->fetch()) {
$id = $row['id'];
$entryauthor = $row['author'];
$entrytitle = $row['title'];
$entrytext = $row['msg'];
$entryemail = $row['email'];
$date = $row['fate'];
$blog = $row['blog'];
// Run the script if submitted
if ($_POST['submit']) {
$id = $row['id'];
$entryauthor = $row['author'];
$entrytitle = $row['title'];
$entrytext = $row['msg'];
$entryemail = $row['email'];
$date = $row['fate'];
$blog = $row['blog'];
if (! $entrytitle) {
echo "<div class=\"title\">Error!</div>";
echo "<div class=\"normal\">You did not fill out the title fields! <br /> Please go back!</div>";
exit();
}
if (! $entrytext) {
echo "<div class=\"title\">Error!</div>";
echo "<div class=\"normal\">You did not fill out the message field! <br /> Please go back and correct this!</div>";
exit();
}
// Sanitize the data! Implement BBCode!
$entryauthor = $dataClean->clean($entryauthor); // Clean the author
$entryemail = $dataClean->clean($entryemail); // Clean the email
$entrytitle = $dataClean->clean($entrytitle); // Clean the title
$entrytext = $dataClean->clean($entrytext); // Clean the text
$entrytitle = $dataClean->bbcode($entrytitle); // Add BBcode!
$entrytext = $dataClean->bbcode($entrytext); // Add BBCode!
// SQL query...
$gdnps2 = "UPDATE gdnps SET author='$entryauthor', title='$entrytitle', msg='$entrytext', ";
$gdnps2 .= "ip='$ip', blog='$entryblog' WHERE id='$editReply'";
// Process said query
$db->query($gdnps2);
if (! $db->isError())
echo "<div class=\"title\">Success!</div><div class=\"normal\"><a href=\"blog.php?blog=$cookie_blog\" "
. "class=\"doc\">Click here to return to the home of $cookie_blog</a></div>";
else
echo "<div class=\"title\">Error!</div><div class=\"normal\">This was NOT posted!</div>";
} else {
echo "<div class=\"title\">Edit your Entry</div>";
echo "<div class=\"normal\">";
echo "<a href=\"javascript:bbcode()\" class=\"doc\">BB Code</a>";
echo "<form method=\"post\" action=\"$php_self\">";
echo "<p> <input type=\"hidden\" name=\"id\" value=\"$id\" /> </p>";
echo "<p> <input type=\"hidden\" name=\"entryauthor\" value=\"$cookie_name\" /> </p>";
echo "<p> <input type=\"hidden\" name=\"ip\" value=\"$usrip\" /> </p>";
echo "<p> Title </p>";
echo "<p> <input type=\"text\" name=\"entrytitle\" value=\"$entrytitle\" /> </p>";
echo "<p> Message </p>";
echo "<p> <textarea cols=\"40\" rows=\"10\" name=\"entrytext\">$entrytext</textarea>";
echo "<p> <input type=\"submit\" name=\"submit\" value=\"Submit\" /> <input type=\"reset\" name=\"reset\" value=\"Reset\" /> </p>";
echo "</form>";
echo "</div>";
}
}
}
// Require footer
require_once('rf/foot.php');
?>
page, but as you can see... eh; not very good. When I tried it, I get this error:
Its nearly 3AM, and I can't figure it out for the life of me.Notice: Query failed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 's try it again!', ip='127.0.0.1', blog='' WHERE id=''' at line SQL: UPDATE gdnps SET author='Jonathan', title='', msg='Let's try it again!', ip='127.0.0.1', blog='' WHERE id='' in E:\xampp\xampp\htdocs\actual\Last Entry\rf\class.php on line 49
Error!
This was NOT posted!




Bookmarks